[gimp] libgimpcolor: add gimp_lcms_profile_is_rgb() and _is_cmyk()



commit ebc53672cb8f26442b37273333b8d97a56ccc691
Author: Michael Natterer <mitch gimp org>
Date:   Sat Mar 15 21:46:02 2014 +0100

    libgimpcolor: add gimp_lcms_profile_is_rgb() and _is_cmyk()
    
    And change all lcms code to use it.

 libgimpcolor/gimpcolor.def     |    2 ++
 libgimpcolor/gimplcms.c        |   16 ++++++++++++++++
 libgimpcolor/gimplcms.h        |    3 +++
 modules/display-filter-lcms.c  |    9 +--------
 plug-ins/common/lcms.c         |   16 +++++-----------
 plug-ins/file-jpeg/jpeg-load.c |    6 +++---
 6 files changed, 30 insertions(+), 22 deletions(-)
---
diff --git a/libgimpcolor/gimpcolor.def b/libgimpcolor/gimpcolor.def
index c40f29d..4e8ded4 100644
--- a/libgimpcolor/gimpcolor.def
+++ b/libgimpcolor/gimpcolor.def
@@ -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
diff --git a/libgimpcolor/gimplcms.c b/libgimpcolor/gimplcms.c
index 4e3a708..2094925 100644
--- a/libgimpcolor/gimplcms.c
+++ b/libgimpcolor/gimplcms.c
@@ -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,
diff --git a/libgimpcolor/gimplcms.h b/libgimpcolor/gimplcms.h
index 94b70f3..60c7a97 100644
--- a/libgimpcolor/gimplcms.h
+++ b/libgimpcolor/gimplcms.h
@@ -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);
 
 
diff --git a/modules/display-filter-lcms.c b/modules/display-filter-lcms.c
index 291bf87..e65d672 100644
--- a/modules/display-filter-lcms.c
+++ b/modules/display-filter-lcms.c
@@ -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;
diff --git a/plug-ins/common/lcms.c b/plug-ins/common/lcms.c
index 0dc0920..c39e0fc 100644
--- a/plug-ins/common/lcms.c
+++ b/plug-ins/common/lcms.c
@@ -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,
diff --git a/plug-ins/file-jpeg/jpeg-load.c b/plug-ins/file-jpeg/jpeg-load.c
index d31aa88..a264200 100644
--- a/plug-ins/file-jpeg/jpeg-load.c
+++ b/plug-ins/file-jpeg/jpeg-load.c
@@ -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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]