Bug 61829 - PNG gamme correction doesn't work
Summary: PNG gamme correction doesn't work
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Unmaintained
Component: kimgio (show other bugs)
Version: SVN
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-30 02:31 UTC by sfricke
Modified: 2005-11-04 07:23 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Patch, as proposed to TT (1.18 KB, text/plain)
2004-08-25 10:48 UTC, Brad Hards
Details

Note You need to log in before you can comment on or make changes to this bug.
Description sfricke 2003-07-30 02:31:08 UTC
Version:            (using KDE KDE 3.1.1a)
Installed from:    SuSE RPMs
OS:          Linux

An example can be found here:

http://www.christian-seiler.de/temp/gamma.html

The left picture looks differently in Konqueror and Mozilla.

Stefan
Comment 1 Thiago Macieira 2003-07-30 12:57:56 UTC
Confirmed for CVS HEAD. 
Comment 2 Brad Hards 2004-08-25 10:47:23 UTC
This appears to be a Qt bug. I've sent a bug report (with a suggested fix) to qt-bugs. Will wait for a response before closing.
Comment 3 Brad Hards 2004-08-25 10:48:33 UTC
Created attachment 7269 [details]
Patch, as proposed to TT
Comment 4 Brad Hards 2004-09-07 16:39:41 UTC
CVS commit by bhards: 

This patch fixes a bug report that was logged against KDE for not
handling gamma correctly (http://bugs.kde.org/show_bug.cgi?id=61829).

Using the example/showimg/showimg example in qt-3.3, the two test
case images (linked in the original bug report) look the same.
That isn't the case with a non-Qt based application, such as Mozilla.

The gamma-yes.png file should look a lot lighter in the blue section.

The problem is in src/kernel/qpngio.cpp::setup_qt()
    if ( screen_gamma != 0.0 && png_get_valid(png_ptr, info_ptr,PNG_INFO_gAMA) ) {
        double file_gamma;
        png_get_gAMA(png_ptr, info_ptr, &file_gamma);
        png_set_gamma( png_ptr, screen_gamma, file_gamma );
    }
which is wrong, because file gamma needs to be handled whether or not
there is a non-default screen gamma value.

qt-bugs@TT issue : N55198

CCMAIL: 61829-done@bugs.kde.org


  A            0053-png-gamma-fix.diff   1.1
  M +1 -1      README   1.28


--- qt-copy/patches/README  #1.27:1.28
@@ -1,4 +1,4 @@
 Please assign the numbers incrementally, and don't reuse them. The next one:
-#0053
+#0054
 
 This directory contains patches for Qt that haven't been accepted by TrollTech


Comment 5 Charles Samuels 2005-11-02 14:25:40 UTC
SVN commit 476941 by charles:


Fix gamma correction semi-properly.  The patch that does it incorrectly
in qt-copy should go away now.

This has seen minimal review on kfm-devel...

CCMAIL:61829@bugs.kde.org



 M  +11 -2     loader.cpp  


--- branches/KDE/3.5/kdelibs/khtml/misc/loader.cpp #476940:476941
@@ -821,7 +821,16 @@
 #ifdef CACHE_DEBUG
             kdDebug(6060) << "CachedImage::data(): reloading as pixmap:" << endl;
 #endif
-            p = new QPixmap( _buffer.buffer() );
+            p = new QPixmap;
+            {
+            	QBuffer buffer(_buffer.buffer());
+            	buffer.open(IO_ReadOnly);
+                QImageIO io( &buffer, 0 );
+                io.setGamma(2.2); // hardcoded "reasonable value"
+                bool result = io.read();
+                if (result) p->convertFromImage(io.image(), 0);
+            }
+
             // set size of image.
 #ifdef CACHE_DEBUG
             kdDebug(6060) << "CachedImage::data(): image is null: " << p->isNull() << endl;
@@ -836,7 +845,7 @@
 
             for (QPtrDictIterator<CachedObjectClient> it( m_clients ); it.current();)
                 it()->notifyFinished( this );
-	    m_status = Cached; //all done
+            m_status = Cached; //all done
         }
     }
 }
Comment 6 Brad Hards 2005-11-04 07:23:08 UTC
I can see how that might work around the problem for khtml, but what about the direct users of kimgio? 

Also, can you tell me what you think is wrong with the qt-copy patch?

Brad