evince r3590 - in branches/gnome-2-26: . backend/tiff



Author: bberg
Date: Thu Apr  9 20:36:29 2009
New Revision: 3590
URL: http://svn.gnome.org/viewvc/evince?rev=3590&view=rev

Log:
2009-04-09  Benjamin Berg  <benjamin sipsolutions net>

	* backend/tiff/tiff-document.c: (tiff_document_render):
	Fix tiff pixel conversion on big endian machines. Fixes bug #509920.


Modified:
   branches/gnome-2-26/ChangeLog
   branches/gnome-2-26/backend/tiff/tiff-document.c

Modified: branches/gnome-2-26/backend/tiff/tiff-document.c
==============================================================================
--- branches/gnome-2-26/backend/tiff/tiff-document.c	(original)
+++ branches/gnome-2-26/backend/tiff/tiff-document.c	Thu Apr  9 20:36:29 2009
@@ -260,10 +260,10 @@
 	rowstride = cairo_format_stride_for_width (CAIRO_FORMAT_RGB24, width);
 #else
 	rowstride = width * 4;
+#endif
 	if (rowstride / 4 != width)
-		/* overflow */
+		/* overflow, or cairo was changed in an unsupported way */
 		return NULL;                
-#endif
 	
 	bytes = height * rowstride;
 	if (bytes / rowstride != height)
@@ -292,16 +292,15 @@
 	*/
 	p = pixels;
 	while (p < pixels + bytes) {
-		uint32 pixel = *(uint32 *)p;
-		int r = TIFFGetR(pixel);
-		int g = TIFFGetG(pixel);
-		int b = TIFFGetB(pixel);
-		int a = TIFFGetA(pixel);
-		
-		*p++ = b;
-		*p++ = g;
-		*p++ = r;
-		*p++ = a;
+		guint32 *pixel = (guint32*)p;
+		guint8 r = TIFFGetR(*pixel);
+		guint8 g = TIFFGetG(*pixel);
+		guint8 b = TIFFGetB(*pixel);
+		guint8 a = TIFFGetA(*pixel);
+
+		*pixel = (a << 24) | (r << 16) | (g << 8) | b;
+
+		p += 4;
 	}
 
 	rotated_surface = ev_document_misc_surface_rotate_and_scale (surface,



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