Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Berg <benjamin@sipsolutions.net>2009-04-09 20:36:17 (GMT)
committer Benjamin Berg <bberg@src.gnome.org>2009-04-09 20:36:17 (GMT)
commit55cba8c3fe89f3baf75dd0d84f79a0e0d9c8eed0 (patch)
tree1f29a5639e0bc1b06e8818e6351923a36a2b1f88
parent1fa82889458f44a61704e7c47d1de77276c87bc7 (diff)
Fix tiff pixel conversion on big endian machines. Fixes bug #509920.
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. svn path=/trunk/; revision=3589
-rw-r--r--ChangeLog5
-rw-r--r--backend/tiff/tiff-document.c23
2 files changed, 16 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 1c9c047..7a1b24f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
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.
+
+2009-04-09 Benjamin Berg <benjamin@sipsolutions.net>
+
* backend/dvi/cairo-device.c: (dvi_cairo_put_pixel):
Fix output on big endian machines. Fixes bug #578433.
diff --git a/backend/tiff/tiff-document.c b/backend/tiff/tiff-document.c
index 5501451..7f10c9a 100644
--- a/backend/tiff/tiff-document.c
+++ b/backend/tiff/tiff-document.c
@@ -260,10 +260,10 @@ tiff_document_render (EvDocument *document,
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 @@ tiff_document_render (EvDocument *document,
*/
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,