mirror of https://github.com/GNOME/gimp.git
Bug 756389 - Color-managing grayscale images
Support creating linear/sRGB-gamma variants of gray profiles and rename gimp_color_profile_new_linear_rgb_from_color_profile() to gimp_color_profile_new_linear_gamma_from_color_profile() because it's not RGB-specific any longer.
This commit is contained in:
parent
bb482badf0
commit
11e8cacf7e
|
@ -173,7 +173,7 @@ gimp_image_convert_precision (GimpImage *image,
|
|||
if (gimp_babl_format_get_linear (new_format))
|
||||
{
|
||||
new_profile =
|
||||
gimp_color_profile_new_linear_rgb_from_color_profile (old_profile);
|
||||
gimp_color_profile_new_linear_gamma_from_color_profile (old_profile);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1136,7 +1136,7 @@ gimp_layer_convert_type (GimpDrawable *drawable,
|
|||
if (gimp_babl_format_get_linear (new_format))
|
||||
{
|
||||
dest_profile =
|
||||
gimp_color_profile_new_linear_rgb_from_color_profile (src_profile);
|
||||
gimp_color_profile_new_linear_gamma_from_color_profile (src_profile);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -44,9 +44,9 @@ EXPORTS
|
|||
gimp_color_profile_new_from_file
|
||||
gimp_color_profile_new_from_icc_profile
|
||||
gimp_color_profile_new_from_lcms_profile
|
||||
gimp_color_profile_new_linear_gamma_from_color_profile
|
||||
gimp_color_profile_new_linear_gray
|
||||
gimp_color_profile_new_linear_rgb
|
||||
gimp_color_profile_new_linear_rgb_from_color_profile
|
||||
gimp_color_profile_new_srgb
|
||||
gimp_color_profile_new_srgb_gray
|
||||
gimp_color_profile_new_srgb_gamma_from_color_profile
|
||||
|
|
|
@ -788,10 +788,7 @@ gimp_color_profile_new_from_color_profile (GimpColorProfile *profile,
|
|||
{
|
||||
GimpColorProfile *new_profile;
|
||||
cmsHPROFILE target_profile;
|
||||
GimpMatrix3 matrix;
|
||||
cmsCIEXYZ red;
|
||||
cmsCIEXYZ green;
|
||||
cmsCIEXYZ blue;
|
||||
GimpMatrix3 matrix = { 0, };
|
||||
cmsCIEXYZ *whitepoint;
|
||||
cmsToneCurve *curve;
|
||||
const gchar *model;
|
||||
|
@ -799,37 +796,27 @@ gimp_color_profile_new_from_color_profile (GimpColorProfile *profile,
|
|||
|
||||
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
|
||||
|
||||
if (! gimp_color_profile_get_rgb_matrix_colorants (profile, &matrix))
|
||||
return NULL;
|
||||
if (gimp_color_profile_is_rgb (profile))
|
||||
{
|
||||
if (! gimp_color_profile_get_rgb_matrix_colorants (profile, &matrix))
|
||||
return NULL;
|
||||
}
|
||||
else if (! gimp_color_profile_is_gray (profile))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
whitepoint = cmsReadTag (profile->priv->lcms_profile,
|
||||
cmsSigMediaWhitePointTag);
|
||||
|
||||
red.X = matrix.coeff[0][0];
|
||||
red.Y = matrix.coeff[0][1];
|
||||
red.Z = matrix.coeff[0][2];
|
||||
|
||||
green.X = matrix.coeff[1][0];
|
||||
green.Y = matrix.coeff[1][1];
|
||||
green.Z = matrix.coeff[1][2];
|
||||
|
||||
blue.X = matrix.coeff[2][0];
|
||||
blue.Y = matrix.coeff[2][1];
|
||||
blue.Z = matrix.coeff[2][2];
|
||||
|
||||
target_profile = cmsCreateProfilePlaceholder (0);
|
||||
|
||||
cmsSetProfileVersion (target_profile, 4.3);
|
||||
cmsSetDeviceClass (target_profile, cmsSigDisplayClass);
|
||||
cmsSetColorSpace (target_profile, cmsSigRgbData);
|
||||
cmsSetPCS (target_profile, cmsSigXYZData);
|
||||
|
||||
cmsWriteTag (target_profile, cmsSigMediaWhitePointTag, whitepoint);
|
||||
|
||||
cmsWriteTag (target_profile, cmsSigRedColorantTag, &red);
|
||||
cmsWriteTag (target_profile, cmsSigGreenColorantTag, &green);
|
||||
cmsWriteTag (target_profile, cmsSigBlueColorantTag, &blue);
|
||||
|
||||
if (linear)
|
||||
{
|
||||
/* linear light */
|
||||
|
@ -850,9 +837,40 @@ gimp_color_profile_new_from_color_profile (GimpColorProfile *profile,
|
|||
"sRGB gamma variant generated by GIMP");
|
||||
}
|
||||
|
||||
cmsWriteTag (target_profile, cmsSigRedTRCTag, curve);
|
||||
cmsWriteTag (target_profile, cmsSigGreenTRCTag, curve);
|
||||
cmsWriteTag (target_profile, cmsSigBlueTRCTag, curve);
|
||||
if (gimp_color_profile_is_rgb (profile))
|
||||
{
|
||||
cmsCIEXYZ red;
|
||||
cmsCIEXYZ green;
|
||||
cmsCIEXYZ blue;
|
||||
|
||||
cmsSetColorSpace (target_profile, cmsSigRgbData);
|
||||
|
||||
red.X = matrix.coeff[0][0];
|
||||
red.Y = matrix.coeff[0][1];
|
||||
red.Z = matrix.coeff[0][2];
|
||||
|
||||
green.X = matrix.coeff[1][0];
|
||||
green.Y = matrix.coeff[1][1];
|
||||
green.Z = matrix.coeff[1][2];
|
||||
|
||||
blue.X = matrix.coeff[2][0];
|
||||
blue.Y = matrix.coeff[2][1];
|
||||
blue.Z = matrix.coeff[2][2];
|
||||
|
||||
cmsWriteTag (target_profile, cmsSigRedColorantTag, &red);
|
||||
cmsWriteTag (target_profile, cmsSigGreenColorantTag, &green);
|
||||
cmsWriteTag (target_profile, cmsSigBlueColorantTag, &blue);
|
||||
|
||||
cmsWriteTag (target_profile, cmsSigRedTRCTag, curve);
|
||||
cmsWriteTag (target_profile, cmsSigGreenTRCTag, curve);
|
||||
cmsWriteTag (target_profile, cmsSigBlueTRCTag, curve);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmsSetColorSpace (target_profile, cmsSigGrayData);
|
||||
|
||||
cmsWriteTag (target_profile, cmsSigGrayTRCTag, curve);
|
||||
}
|
||||
|
||||
cmsFreeToneCurve (curve);
|
||||
|
||||
|
@ -906,7 +924,7 @@ gimp_color_profile_new_srgb_gamma_from_color_profile (GimpColorProfile *profile)
|
|||
}
|
||||
|
||||
/**
|
||||
* gimp_color_profile_new_linear_rgb_from_color_profile:
|
||||
* gimp_color_profile_new_linear_gamma_from_color_profile:
|
||||
* @profile: a #GimpColorProfile
|
||||
*
|
||||
* This function creates a new RGB #GimpColorProfile with a linear TRC
|
||||
|
@ -918,7 +936,7 @@ gimp_color_profile_new_srgb_gamma_from_color_profile (GimpColorProfile *profile)
|
|||
* Since: 2.10
|
||||
**/
|
||||
GimpColorProfile *
|
||||
gimp_color_profile_new_linear_rgb_from_color_profile (GimpColorProfile *profile)
|
||||
gimp_color_profile_new_linear_gamma_from_color_profile (GimpColorProfile *profile)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
|
||||
|
||||
|
|
|
@ -72,9 +72,9 @@ GimpColorProfile * gimp_color_profile_new_srgb_gray (void);
|
|||
GimpColorProfile * gimp_color_profile_new_linear_gray (void);
|
||||
|
||||
GimpColorProfile *
|
||||
gimp_color_profile_new_srgb_gamma_from_color_profile (GimpColorProfile *profile);
|
||||
gimp_color_profile_new_srgb_gamma_from_color_profile (GimpColorProfile *profile);
|
||||
GimpColorProfile *
|
||||
gimp_color_profile_new_linear_rgb_from_color_profile (GimpColorProfile *profile);
|
||||
gimp_color_profile_new_linear_gamma_from_color_profile (GimpColorProfile *profile);
|
||||
|
||||
GimpColorProfile * gimp_color_profile_new_from_file (GFile *file,
|
||||
GError **error);
|
||||
|
|
Loading…
Reference in New Issue