libgimpcolor: add gimp_lcms_profile_is_rgb() and _is_cmyk()

And change all lcms code to use it.
This commit is contained in:
Michael Natterer 2014-03-15 21:46:02 +01:00
parent a277a5b66f
commit ebc53672cb
6 changed files with 30 additions and 22 deletions

View File

@ -43,6 +43,8 @@ EXPORTS
gimp_lcms_profile_get_manufacturer
gimp_lcms_profile_get_model
gimp_lcms_profile_get_summary
gimp_lcms_profile_is_cmyk
gimp_lcms_profile_is_rgb
gimp_param_rgb_get_type
gimp_param_spec_rgb
gimp_param_spec_rgb_has_alpha

View File

@ -142,6 +142,22 @@ gimp_lcms_profile_get_summary (GimpColorProfile profile)
return g_string_free (string, FALSE);
}
gboolean
gimp_lcms_profile_is_rgb (GimpColorProfile profile)
{
g_return_val_if_fail (profile != NULL, FALSE);
return (cmsGetColorSpace (profile) == cmsSigRgbData);
}
gboolean
gimp_lcms_profile_is_cmyk (GimpColorProfile profile)
{
g_return_val_if_fail (profile != NULL, FALSE);
return (cmsGetColorSpace (profile) == cmsSigCmykData);
}
static void
gimp_lcms_profile_set_tag (cmsHPROFILE profile,
cmsTagSignature sig,

View File

@ -42,6 +42,9 @@ gchar * gimp_lcms_profile_get_copyright (GimpColorProfile profile)
gchar * gimp_lcms_profile_get_summary (GimpColorProfile profile);
gboolean gimp_lcms_profile_is_rgb (GimpColorProfile profile);
gboolean gimp_lcms_profile_is_cmyk (GimpColorProfile profile);
GimpColorProfile gimp_lcms_create_srgb_profile (void);

View File

@ -381,12 +381,6 @@ cdisplay_lcms_changed (GimpColorDisplay *display)
cmsCloseProfile (src_profile);
}
static gboolean
cdisplay_lcms_profile_is_rgb (cmsHPROFILE profile)
{
return (cmsGetColorSpace (profile) == cmsSigRgbData);
}
static cmsHPROFILE
cdisplay_lcms_get_rgb_profile (CdisplayLcms *lcms)
{
@ -404,8 +398,7 @@ cdisplay_lcms_get_rgb_profile (CdisplayLcms *lcms)
if (data)
profile = cmsOpenProfileFromMem ((gpointer) data, len);
if (profile &&
! cdisplay_lcms_profile_is_rgb (profile))
if (profile && ! gimp_lcms_profile_is_rgb (profile))
{
cmsCloseProfile (profile);
profile = NULL;

View File

@ -493,12 +493,6 @@ run (const gchar *name,
values[0].data.d_status = status;
}
static gboolean
lcms_icc_profile_is_rgb (cmsHPROFILE profile)
{
return (cmsGetColorSpace (profile) == cmsSigRgbData);
}
static GimpPDBStatusType
lcms_icc_set (GimpColorConfig *config,
gint32 image,
@ -545,7 +539,7 @@ lcms_icc_apply (GimpColorConfig *config,
if (! dest_profile)
return GIMP_PDB_EXECUTION_ERROR;
if (! lcms_icc_profile_is_rgb (dest_profile))
if (! gimp_lcms_profile_is_rgb (dest_profile))
{
g_message (_("Color profile '%s' is not for RGB color space."),
gimp_filename_to_utf8 (filename));
@ -557,7 +551,7 @@ lcms_icc_apply (GimpColorConfig *config,
src_profile = lcms_image_get_profile (config, image, src_md5);
if (src_profile && ! lcms_icc_profile_is_rgb (src_profile))
if (src_profile && ! gimp_lcms_profile_is_rgb (src_profile))
{
g_printerr ("lcms: attached color profile is not for RGB color space "
"(skipping)\n");
@ -633,7 +627,7 @@ lcms_icc_info (GimpColorConfig *config,
profile = lcms_image_get_profile (config, image, NULL);
if (profile && ! lcms_icc_profile_is_rgb (profile))
if (profile && ! gimp_lcms_profile_is_rgb (profile))
{
g_printerr ("lcms: attached color profile is not for RGB color space "
"(skipping)\n");
@ -1418,7 +1412,7 @@ lcms_dialog (GimpColorConfig *config,
src_profile = lcms_image_get_profile (config, image, NULL);
if (src_profile && ! lcms_icc_profile_is_rgb (src_profile))
if (src_profile && ! gimp_lcms_profile_is_rgb (src_profile))
{
g_printerr ("lcms: attached color profile is not for RGB color space "
"(skipping)\n");
@ -1543,7 +1537,7 @@ lcms_dialog (GimpColorConfig *config,
if (dest_profile)
{
if (lcms_icc_profile_is_rgb (dest_profile))
if (gimp_lcms_profile_is_rgb (dest_profile))
{
if (apply)
success = lcms_image_apply_profile (image,

View File

@ -606,7 +606,7 @@ jpeg_load_cmyk_transform (guint8 *profile_data,
if (cmyk_profile)
{
if (cmsGetColorSpace (cmyk_profile) != cmsSigCmykData)
if (! gimp_lcms_profile_is_cmyk (cmyk_profile))
{
cmsCloseProfile (cmyk_profile);
cmyk_profile = NULL;
@ -619,7 +619,7 @@ jpeg_load_cmyk_transform (guint8 *profile_data,
{
cmyk_profile = cmsOpenProfileFromFile (config->cmyk_profile, "r");
if (cmyk_profile && cmsGetColorSpace (cmyk_profile) != cmsSigCmykData)
if (cmyk_profile && ! gimp_lcms_profile_is_cmyk (cmyk_profile))
{
cmsCloseProfile (cmyk_profile);
cmyk_profile = NULL;
@ -638,7 +638,7 @@ jpeg_load_cmyk_transform (guint8 *profile_data,
{
rgb_profile = cmsOpenProfileFromFile (config->rgb_profile, "r");
if (rgb_profile && cmsGetColorSpace (rgb_profile) != cmsSigRgbData)
if (rgb_profile && ! gimp_lcms_profile_is_rgb (rgb_profile))
{
cmsCloseProfile (rgb_profile);
rgb_profile = NULL;