[eog] EogImage: Check GdkPixbuf for an ICC profile before falling back to sRGB



commit 48e971cbccc35b43e351fbefb41c4a54246b47ac
Author: Felix Riemann <friemann gnome org>
Date:   Wed Apr 2 22:10:24 2014 +0200

    EogImage: Check GdkPixbuf for an ICC profile before falling back to sRGB
    
    If an image's ICC profile cannot be extracted check whether GdkPixbuf
    was able to extract one before falling back to sRGB. This makes it
    possible to color correct TIFF images.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=727467

 src/eog-image.c |   30 ++++++++++++++++++++++++++----
 1 files changed, 26 insertions(+), 4 deletions(-)
---
diff --git a/src/eog-image.c b/src/eog-image.c
index 1b7ef7e..b11c8cb 100644
--- a/src/eog-image.c
+++ b/src/eog-image.c
@@ -696,10 +696,32 @@ eog_image_apply_display_profile (EogImage *img, cmsHPROFILE screen)
        if (screen == NULL) return;
 
        if (priv->profile == NULL) {
-               /* Assume sRGB color space for images without ICC profile */
-               eog_debug_message (DEBUG_LCMS, "Image has no ICC profile. "
-                                  "Assuming sRGB.");
-               priv->profile = cmsCreate_sRGBProfile ();
+               /* Check whether GdkPixbuf was able to extract a profile */
+               const char* data = gdk_pixbuf_get_option (priv->image,
+                                                         "icc-profile");
+
+               if(data) {
+                       gsize   profile_size = 0;
+                       guchar *profile_data = g_base64_decode(data,
+                                                              &profile_size);
+
+                       if (profile_data && profile_size > 0) {
+                               eog_debug_message (DEBUG_LCMS,
+                                                  "Using ICC profile "
+                                                  "extracted by GdkPixbuf");
+                               priv->profile =
+                                       cmsOpenProfileFromMem(profile_data,
+                                                             profile_size);
+                               g_free(profile_data);
+                       }
+               }
+
+               if(priv->profile == NULL) {
+                       /* Assume sRGB color space for images without ICC profile */
+                       eog_debug_message (DEBUG_LCMS, "Image has no ICC profile. "
+                                          "Assuming sRGB.");
+                       priv->profile = cmsCreate_sRGBProfile ();
+               }
        }
 
        /* TODO: support other colorspaces than RGB */


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