[gimp] libgimpcolor: return an optional MD5 digest from gimp_lcms_create_srgb_profile()



commit b3395d989e79644e924bac65b7da74d593e77faa
Author: Michael Natterer <mitch gimp org>
Date:   Sun Mar 23 23:34:47 2014 +0100

    libgimpcolor: return an optional MD5 digest from gimp_lcms_create_srgb_profile()
    
    pass NULL in most places, use the feature in the lcms.c plu-gin.

 app/widgets/gimpimageprofileview.c |    2 +-
 libgimpcolor/gimplcms.c            |   22 ++++++++++++++++++-
 libgimpcolor/gimplcms.h            |    2 +-
 modules/color-selector-cmyk.c      |    2 +-
 modules/display-filter-lcms.c      |    8 +++---
 modules/display-filter-proof.c     |    2 +-
 plug-ins/common/lcms.c             |   40 +++++------------------------------
 plug-ins/file-jpeg/jpeg-load.c     |    2 +-
 8 files changed, 36 insertions(+), 44 deletions(-)
---
diff --git a/app/widgets/gimpimageprofileview.c b/app/widgets/gimpimageprofileview.c
index 68a7a37..d5b342a 100644
--- a/app/widgets/gimpimageprofileview.c
+++ b/app/widgets/gimpimageprofileview.c
@@ -120,7 +120,7 @@ gimp_image_profile_view_update (GimpImageParasiteView *view)
     }
 
   if (! profile)
-    profile = gimp_lcms_create_srgb_profile ();
+    profile = gimp_lcms_create_srgb_profile (NULL);
 
   gimp_color_profile_view_set_profile (profile_view->profile_view, profile);
 
diff --git a/libgimpcolor/gimplcms.c b/libgimpcolor/gimplcms.c
index aedb787..da30f8e 100644
--- a/libgimpcolor/gimplcms.c
+++ b/libgimpcolor/gimplcms.c
@@ -297,7 +297,7 @@ gimp_lcms_profile_set_tag (cmsHPROFILE      profile,
  * Since: GIMP 2.10
  **/
 GimpColorProfile
-gimp_lcms_create_srgb_profile (void)
+gimp_lcms_create_srgb_profile (guint8 *md5_digest)
 {
   cmsHPROFILE srgb_profile;
   cmsCIExyY   d65_srgb_specs = { 0.3127, 0.3290, 1.0 };
@@ -345,5 +345,25 @@ gimp_lcms_create_srgb_profile (void)
    * cmsSetProfileVersion (srgb_profile, 2.1);
    **/
 
+  if (md5_digest)
+    {
+      md5_digest[0]  = 0xcb;
+      md5_digest[1]  = 0x63;
+      md5_digest[2]  = 0x14;
+      md5_digest[3]  = 0x56;
+      md5_digest[4]  = 0xd4;
+      md5_digest[5]  = 0x0a;
+      md5_digest[6]  = 0x01;
+      md5_digest[7]  = 0x62;
+      md5_digest[8]  = 0xa0;
+      md5_digest[9]  = 0xdb;
+      md5_digest[10] = 0xe6;
+      md5_digest[11] = 0x32;
+      md5_digest[12] = 0x8b;
+      md5_digest[13] = 0xea;
+      md5_digest[14] = 0x1a;
+      md5_digest[15] = 0x89;
+    }
+
   return srgb_profile;
 }
diff --git a/libgimpcolor/gimplcms.h b/libgimpcolor/gimplcms.h
index b3a032d..4f1749d 100644
--- a/libgimpcolor/gimplcms.h
+++ b/libgimpcolor/gimplcms.h
@@ -53,7 +53,7 @@ gchar            * gimp_lcms_profile_get_summary      (GimpColorProfile   profil
 gboolean           gimp_lcms_profile_is_rgb           (GimpColorProfile   profile);
 gboolean           gimp_lcms_profile_is_cmyk          (GimpColorProfile   profile);
 
-GimpColorProfile   gimp_lcms_create_srgb_profile      (void);
+GimpColorProfile   gimp_lcms_create_srgb_profile      (guint8            *md5_digest);
 
 
 G_END_DECLS
diff --git a/modules/color-selector-cmyk.c b/modules/color-selector-cmyk.c
index 420a7d5..fac9e56 100644
--- a/modules/color-selector-cmyk.c
+++ b/modules/color-selector-cmyk.c
@@ -357,7 +357,7 @@ color_config_get_rgb_profile (GimpColorConfig *config)
   if (config->rgb_profile)
     profile = cmsOpenProfileFromFile (config->rgb_profile, "r");
 
-  return profile ? profile : gimp_lcms_create_srgb_profile ();
+  return profile ? profile : gimp_lcms_create_srgb_profile (NULL);
 }
 
 static cmsHPROFILE
diff --git a/modules/display-filter-lcms.c b/modules/display-filter-lcms.c
index dbb1aea..abc66c9 100644
--- a/modules/display-filter-lcms.c
+++ b/modules/display-filter-lcms.c
@@ -318,10 +318,10 @@ cdisplay_lcms_changed (GimpColorDisplay *display)
       cmsUInt32Number softproof_flags = 0;
 
       if (! src_profile)
-        src_profile = gimp_lcms_create_srgb_profile ();
+        src_profile = gimp_lcms_create_srgb_profile (NULL);
 
       if (! dest_profile)
-        dest_profile = gimp_lcms_create_srgb_profile ();
+        dest_profile = gimp_lcms_create_srgb_profile (NULL);
 
       softproof_flags |= cmsFLAGS_SOFTPROOFING;
 
@@ -358,10 +358,10 @@ cdisplay_lcms_changed (GimpColorDisplay *display)
       cmsUInt32Number display_flags = 0;
 
       if (! src_profile)
-        src_profile = gimp_lcms_create_srgb_profile ();
+        src_profile = gimp_lcms_create_srgb_profile (NULL);
 
       if (! dest_profile)
-        dest_profile = gimp_lcms_create_srgb_profile ();
+        dest_profile = gimp_lcms_create_srgb_profile (NULL);
 
       if (config->display_use_black_point_compensation)
         {
diff --git a/modules/display-filter-proof.c b/modules/display-filter-proof.c
index 7a41f49..2f1b263 100644
--- a/modules/display-filter-proof.c
+++ b/modules/display-filter-proof.c
@@ -384,7 +384,7 @@ cdisplay_proof_changed (GimpColorDisplay *display)
   if (! proof->profile)
     return;
 
-  rgb_profile = gimp_lcms_create_srgb_profile ();
+  rgb_profile = gimp_lcms_create_srgb_profile (NULL);
 
   proof_profile = cmsOpenProfileFromFile (proof->profile, "r");
 
diff --git a/plug-ins/common/lcms.c b/plug-ins/common/lcms.c
index 3c8637e..75d0569 100644
--- a/plug-ins/common/lcms.c
+++ b/plug-ins/common/lcms.c
@@ -136,7 +136,6 @@ static void         lcms_image_transform_indexed (gint32           image,
                                                   cmsHPROFILE      dest_profile,
                                                   GimpColorRenderingIntent intent,
                                                   gboolean          bpc);
-static void         lcms_sRGB_checksum           (guchar          *digest);
 
 static gboolean     lcms_icc_apply_dialog        (gint32           image,
                                                   cmsHPROFILE      src_profile,
@@ -577,16 +576,10 @@ lcms_icc_apply (GimpColorConfig          *config,
     return GIMP_PDB_SUCCESS;
 
   if (! src_profile)
-    {
-      src_profile = gimp_lcms_create_srgb_profile ();
-      lcms_sRGB_checksum (src_md5);
-    }
+    src_profile = gimp_lcms_create_srgb_profile (src_md5);
 
   if (! dest_profile)
-    {
-      dest_profile = gimp_lcms_create_srgb_profile ();
-      lcms_sRGB_checksum (dest_md5);
-    }
+    dest_profile = gimp_lcms_create_srgb_profile (dest_md5);
 
   if (memcmp (src_md5, dest_md5, GIMP_LCMS_MD5_DIGEST_LENGTH) == 0)
     {
@@ -648,7 +641,7 @@ lcms_icc_info (GimpColorConfig *config,
     }
 
   if (! profile)
-    profile = gimp_lcms_create_srgb_profile ();
+    profile = gimp_lcms_create_srgb_profile (NULL);
 
   if (name) *name = gimp_lcms_profile_get_model (profile);
   if (desc) *desc = gimp_lcms_profile_get_description (profile);
@@ -682,27 +675,6 @@ lcms_icc_file_info (const gchar  *filename,
   return GIMP_PDB_SUCCESS;
 }
 
-static void
-lcms_sRGB_checksum (guchar *digest)
-{
-  digest[0]  = 0xcb;
-  digest[1]  = 0x63;
-  digest[2]  = 0x14;
-  digest[3]  = 0x56;
-  digest[4]  = 0xd4;
-  digest[5]  = 0x0a;
-  digest[6]  = 0x01;
-  digest[7]  = 0x62;
-  digest[8]  = 0xa0;
-  digest[9]  = 0xdb;
-  digest[10] = 0xe6;
-  digest[11] = 0x32;
-  digest[12] = 0x8b;
-  digest[13] = 0xea;
-  digest[14] = 0x1a;
-  digest[15] = 0x89;
-}
-
 static cmsHPROFILE
 lcms_image_get_profile (GimpColorConfig  *config,
                         gint32            image,
@@ -1340,7 +1312,7 @@ lcms_icc_combo_box_new (GimpColorConfig *config,
     }
 
   if (! profile)
-    profile = gimp_lcms_create_srgb_profile ();
+    profile = gimp_lcms_create_srgb_profile (NULL);
 
   name = gimp_lcms_profile_get_description (profile);
   if (! name)
@@ -1391,7 +1363,7 @@ lcms_dialog (GimpColorConfig *config,
     }
 
   if (! src_profile)
-    src_profile = gimp_lcms_create_srgb_profile ();
+    src_profile = gimp_lcms_create_srgb_profile (NULL);
 
   gimp_ui_init (PLUG_IN_BINARY, FALSE);
 
@@ -1510,7 +1482,7 @@ lcms_dialog (GimpColorConfig *config,
         }
       else
         {
-          dest_profile = gimp_lcms_create_srgb_profile ();
+          dest_profile = gimp_lcms_create_srgb_profile (NULL);
         }
 
       if (dest_profile)
diff --git a/plug-ins/file-jpeg/jpeg-load.c b/plug-ins/file-jpeg/jpeg-load.c
index a264200..3fcf380 100644
--- a/plug-ins/file-jpeg/jpeg-load.c
+++ b/plug-ins/file-jpeg/jpeg-load.c
@@ -648,7 +648,7 @@ jpeg_load_cmyk_transform (guint8 *profile_data,
   /*  make the real sRGB profile as a fallback  */
   if (! rgb_profile)
     {
-      rgb_profile = gimp_lcms_create_srgb_profile ();
+      rgb_profile = gimp_lcms_create_srgb_profile (NULL);
     }
 
   if (config->display_intent ==


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