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

List:       kde-bugs-dist
Subject:    Bug#953: kimgio returns greyscale jpeg
From:       Carsten Prinz <cprinz () mail ! uni-mainz ! de>
Date:       1999-03-13 15:27:48
[Download RAW message or body]

Package: kdelibs
Version: 1.1

kimgio_jpeg_read (kdelibs/kimgio/jpeg.cpp) returns a 32bpp greyscale
image
 instead of a 32bpp colour image if

a.) QPixmap::defaultDepth() == 32  (32bpp display)
b.) cinfo.quantize_colors == FALSE (jpeg file does *not* use colourmaps)

The problem seems to be caused by the line
 
	*ui_row++ = qRgb(*uc_row++,*uc_row++,*uc_row++);
 	 
which is generally a bad idea since nobody knows which of the three
arguments is evaluated first. egcs-2.91.60 for examples interprets the
above
code as something like
*ui_row++=qRgb(*uc_row,*uc_row,*uc_row);uc_row+=3;
which results in a greyscale, since the r,g,b components are identical.
The below patch should fix the problem


---------------------------------------------
Carsten Prinz
cprinz@mail.uni-mainz.de
---------------------------------------------



--- kdelibs/kimgio/jpeg.cpp.orig        Sat Mar 13 15:31:40 1999
+++ kdelibs/kimgio/jpeg.cpp     Sat Mar 13 15:43:21 1999
@@ -96,7 +96,7 @@
     unsigned char *uc_row, *uc_row_index;
     unsigned depth;
     unsigned col;
-
+    unsigned char r,g,b;
     // We need to know if the display can handle 32-bit images
 
   depth = QPixmap::defaultDepth();
@@ -191,8 +191,12 @@
 
            jpeg_read_scanlines(&cinfo, buffer, 1);
 
-           for (col = 0; col < cinfo.output_width; col++)
-               *ui_row++ = qRgb(*uc_row++, *uc_row++, *uc_row++);
+           for (col = 0; col < cinfo.output_width; col++) {
+                r = *uc_row++;
+                g = *uc_row++;
+                b = *uc_row++;
+                *ui_row++ = qRgb(r,g,b);
+           }
        }
     }

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

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