[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [calligra/calligra/2.4] krita/ui: png export: set sRGB chunk only if the profile sounds like sRGB
From:       Boudewijn Rempt <boud () valdyas ! org>
Date:       2012-03-29 17:15:44
Message-ID: 20120329171544.23084A60A9 () git ! kde ! org
[Download RAW message or body]

Git commit 537a04a892ab7ed150bdf6b19717a7dff88a07ff by Boudewijn Rempt.
Committed on 28/03/2012 at 15:35.
Pushed by rempt into branch 'calligra/2.4'.

png export: set sRGB chunk only if the profile sounds like sRGB

http://www.w3.org/TR/PNG/#11sRGB says sRGB and iCCP should not both be
present

M  +10   -4    krita/ui/kis_png_converter.cpp

http://commits.kde.org/calligra/537a04a892ab7ed150bdf6b19717a7dff88a07ff

diff --git a/krita/ui/kis_png_converter.cpp b/krita/ui/kis_png_converter.cpp
index 3e1bf65..d98e7be 100644
--- a/krita/ui/kis_png_converter.cpp
+++ b/krita/ui/kis_png_converter.cpp
@@ -908,7 +908,12 @@ KisImageBuilder_Result KisPNGConverter::buildFile(QIODevice* iodevice, KisImageW
                  color_type, interlacetype,
                  PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
 
-    png_set_sRGB(png_ptr, info_ptr, PNG_sRGB_INTENT_ABSOLUTE);
+    // set sRGB only if the profile is sRGB  -- http://www.w3.org/TR/PNG/#11sRGB says sRGB and iCCP \
should not both be present +
+    bool sRGB = device->colorSpace()->profile()->name().toLower().contains("srgb");
+    if (sRGB) {
+        png_set_sRGB(png_ptr, info_ptr, PNG_sRGB_INTENT_ABSOLUTE);
+    }
     // set the palette
     if (color_type == PNG_COLOR_TYPE_PALETTE) {
         png_set_PLTE(png_ptr, info_ptr, palette, num_palette);
@@ -949,12 +954,13 @@ KisImageBuilder_Result KisPNGConverter::buildFile(QIODevice* iodevice, KisImageW
     // Save the color profile
     const KoColorProfile* colorProfile = device->colorSpace()->profile();
     QByteArray colorProfileData = colorProfile->rawData();
-    
+    if (!sRGB) {
 #if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 5
-    png_set_iCCP(png_ptr, info_ptr, "icc", PNG_COMPRESSION_TYPE_BASE, (const \
png_bytep)colorProfileData.data(), colorProfileData . size()); +        png_set_iCCP(png_ptr, info_ptr, \
"icc", PNG_COMPRESSION_TYPE_BASE, (const png_bytep)colorProfileData.data(), colorProfileData . size());  \
                #else
-    png_set_iCCP(png_ptr, info_ptr, "icc", PNG_COMPRESSION_TYPE_BASE, (char*)colorProfileData.data(), \
colorProfileData . size()); +        png_set_iCCP(png_ptr, info_ptr, "icc", PNG_COMPRESSION_TYPE_BASE, \
(char*)colorProfileData.data(), colorProfileData . size());  #endif
+    }
 
     // read comments from the document information
     if (m_doc) {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic