mirror of https://github.com/GNOME/gimp.git
libgimpcolor: add API to create profile variants with linear/sRGB gamma
and the original profile's RGB chromacities and whitepoint.
This commit is contained in:
parent
5f7dc5fe3a
commit
6eb9f9d4aa
|
@ -43,7 +43,9 @@ EXPORTS
|
||||||
gimp_color_profile_new_from_icc_profile
|
gimp_color_profile_new_from_icc_profile
|
||||||
gimp_color_profile_new_from_lcms_profile
|
gimp_color_profile_new_from_lcms_profile
|
||||||
gimp_color_profile_new_linear_rgb
|
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
|
||||||
|
gimp_color_profile_new_srgb_gamma_from_color_profile
|
||||||
gimp_hsl_get_type
|
gimp_hsl_get_type
|
||||||
gimp_hsl_set
|
gimp_hsl_set
|
||||||
gimp_hsl_set_alpha
|
gimp_hsl_set_alpha
|
||||||
|
|
|
@ -704,13 +704,9 @@ gimp_color_profile_get_rgb_matrix_colorants (GimpColorProfile *profile,
|
||||||
}
|
}
|
||||||
|
|
||||||
static GimpColorProfile *
|
static GimpColorProfile *
|
||||||
gimp_color_profile_new_from_profile (GimpColorProfile *profile,
|
gimp_color_profile_new_from_color_profile (GimpColorProfile *profile,
|
||||||
gboolean linear)
|
gboolean linear)
|
||||||
{
|
{
|
||||||
/* Make the target RGB working space. Until the ICC allows other
|
|
||||||
* illuminants, and corresponding LCMS code has been added, use the
|
|
||||||
* D50 color space reference white and illuminant.
|
|
||||||
*/
|
|
||||||
GimpColorProfile *new_profile;
|
GimpColorProfile *new_profile;
|
||||||
cmsHPROFILE target_profile;
|
cmsHPROFILE target_profile;
|
||||||
GimpMatrix3 matrix;
|
GimpMatrix3 matrix;
|
||||||
|
@ -719,6 +715,8 @@ gimp_color_profile_new_from_profile (GimpColorProfile *profile,
|
||||||
cmsCIEXYZ blue;
|
cmsCIEXYZ blue;
|
||||||
cmsCIEXYZ *whitepoint;
|
cmsCIEXYZ *whitepoint;
|
||||||
cmsToneCurve *curve;
|
cmsToneCurve *curve;
|
||||||
|
const gchar *model;
|
||||||
|
gchar *new_model;
|
||||||
|
|
||||||
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
|
||||||
|
|
||||||
|
@ -758,8 +756,8 @@ gimp_color_profile_new_from_profile (GimpColorProfile *profile,
|
||||||
/* linear light */
|
/* linear light */
|
||||||
curve = cmsBuildGamma (NULL, 1.00);
|
curve = cmsBuildGamma (NULL, 1.00);
|
||||||
|
|
||||||
gimp_color_profile_set_tag (profile, cmsSigProfileDescriptionTag,
|
gimp_color_profile_set_tag (target_profile, cmsSigProfileDescriptionTag,
|
||||||
"GIMP generated with linear gamma TRC");
|
"linear variant generated by GIMP");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -769,8 +767,8 @@ gimp_color_profile_new_from_profile (GimpColorProfile *profile,
|
||||||
/* sRGB curve */
|
/* sRGB curve */
|
||||||
curve = cmsBuildParametricToneCurve (NULL, 4, srgb_parameters);
|
curve = cmsBuildParametricToneCurve (NULL, 4, srgb_parameters);
|
||||||
|
|
||||||
gimp_color_profile_set_tag (profile, cmsSigProfileDescriptionTag,
|
gimp_color_profile_set_tag (target_profile, cmsSigProfileDescriptionTag,
|
||||||
"GIMP generated with sRGB gamma TRC");
|
"sRGB gamma variant generated by GIMP");
|
||||||
}
|
}
|
||||||
|
|
||||||
cmsWriteTag (target_profile, cmsSigRedTRCTag, curve);
|
cmsWriteTag (target_profile, cmsSigRedTRCTag, curve);
|
||||||
|
@ -779,11 +777,28 @@ gimp_color_profile_new_from_profile (GimpColorProfile *profile,
|
||||||
|
|
||||||
cmsFreeToneCurve (curve);
|
cmsFreeToneCurve (curve);
|
||||||
|
|
||||||
gimp_color_profile_set_tag (profile, cmsSigDeviceMfgDescTag,
|
model = gimp_color_profile_get_model (profile);
|
||||||
|
|
||||||
|
if (model && g_str_has_prefix (model, "Generated from '"))
|
||||||
|
{
|
||||||
|
/* don't add multiple "Generated from 'foo'" */
|
||||||
|
new_model = g_strdup (model);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new_model = g_strdup_printf ("Generated from '%s'",
|
||||||
|
gimp_color_profile_get_description (profile));
|
||||||
|
}
|
||||||
|
|
||||||
|
gimp_color_profile_set_tag (target_profile, cmsSigDeviceMfgDescTag,
|
||||||
"GIMP");
|
"GIMP");
|
||||||
gimp_color_profile_set_tag (profile, cmsSigCopyrightTag,
|
gimp_color_profile_set_tag (target_profile, cmsSigDeviceModelDescTag,
|
||||||
|
new_model);
|
||||||
|
gimp_color_profile_set_tag (target_profile, cmsSigCopyrightTag,
|
||||||
"Public Domain");
|
"Public Domain");
|
||||||
|
|
||||||
|
g_free (new_model);
|
||||||
|
|
||||||
new_profile = gimp_color_profile_new_from_lcms_profile (target_profile, NULL);
|
new_profile = gimp_color_profile_new_from_lcms_profile (target_profile, NULL);
|
||||||
|
|
||||||
cmsCloseProfile (target_profile);
|
cmsCloseProfile (target_profile);
|
||||||
|
@ -791,6 +806,46 @@ gimp_color_profile_new_from_profile (GimpColorProfile *profile,
|
||||||
return new_profile;
|
return new_profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_color_profile_new_srgb_gamma_from_color_profile:
|
||||||
|
* @profile: a #GimpColorProfile
|
||||||
|
*
|
||||||
|
* This function creates a new RGB #GimpColorProfile with a sRGB gamma
|
||||||
|
* TRC and @profile's RGB chromacities and whitepoint.
|
||||||
|
*
|
||||||
|
* Return value: the new #GimpColorProfile, or %NULL if @profile is not
|
||||||
|
* an RGB profile or not matrix-based.
|
||||||
|
*
|
||||||
|
* Since: 2.10
|
||||||
|
**/
|
||||||
|
GimpColorProfile *
|
||||||
|
gimp_color_profile_new_srgb_gamma_from_color_profile (GimpColorProfile *profile)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
|
||||||
|
|
||||||
|
return gimp_color_profile_new_from_color_profile (profile, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_color_profile_new_linear_rgb_from_color_profile:
|
||||||
|
* @profile: a #GimpColorProfile
|
||||||
|
*
|
||||||
|
* This function creates a new RGB #GimpColorProfile with a linear TRC
|
||||||
|
* and @profile's RGB chromacities and whitepoint.
|
||||||
|
*
|
||||||
|
* Return value: the new #GimpColorProfile, or %NULL if @profile is not
|
||||||
|
* an RGB profile or not matrix-based.
|
||||||
|
*
|
||||||
|
* Since: 2.10
|
||||||
|
**/
|
||||||
|
GimpColorProfile *
|
||||||
|
gimp_color_profile_new_linear_rgb_from_color_profile (GimpColorProfile *profile)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
|
||||||
|
|
||||||
|
return gimp_color_profile_new_from_color_profile (profile, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
static cmsHPROFILE *
|
static cmsHPROFILE *
|
||||||
gimp_color_profile_new_srgb_internal (void)
|
gimp_color_profile_new_srgb_internal (void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,6 +69,11 @@ GimpColorProfile * gimp_color_profile_new_linear_rgb (void);
|
||||||
|
|
||||||
GimpColorProfile * gimp_color_profile_new_adobe_rgb (void);
|
GimpColorProfile * gimp_color_profile_new_adobe_rgb (void);
|
||||||
|
|
||||||
|
GimpColorProfile *
|
||||||
|
gimp_color_profile_new_srgb_gamma_from_color_profile (GimpColorProfile *profile);
|
||||||
|
GimpColorProfile *
|
||||||
|
gimp_color_profile_new_linear_rgb_from_color_profile (GimpColorProfile *profile);
|
||||||
|
|
||||||
GimpColorProfile * gimp_color_profile_new_from_file (GFile *file,
|
GimpColorProfile * gimp_color_profile_new_from_file (GFile *file,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue