Endianness bug in tiff plugin
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
When loading a CMYK TIFF (and perhaps other funky kinds of TIFF), the
tiff plugin uses a fallback mode that fills a buffer using
TIFFReadRGBAImage(). This is a uint32 array, and the byte layout of the
pixels ends up wrong on a big-endian host such as my PowerBook.
I've posted a test case and patch on bugzilla:
http://bugzilla.gnome.org/show_bug.cgi?id=147328
Patch is also attached here; it works on my Mac and doesn't seem to
break things on my Linux PC. (HACKING suggests both posting here and
bugzilla; I apologize if I'm being overly rude in this.)
The bug affects at least 2.0.x release versions and current CVS.
- -- brion vibber (brion @ pobox.com)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFA8OXSwRnhpk1wk44RAjtEAJ9zCO+R0NIZuF2nq82kThnKQVWkuQCg04zo
nU46gRCBgkWy7FBsFDGc7L4=
=61/D
-----END PGP SIGNATURE-----
Index: tiff.c
===================================================================
RCS file: /cvs/gnome/gimp/plug-ins/common/tiff.c,v
retrieving revision 1.100
diff -u -r1.100 tiff.c
--- tiff.c 5 Jun 2004 10:27:47 -0000 1.100
+++ tiff.c 11 Jul 2004 06:22:09 -0000
@@ -981,6 +981,12 @@
for (row = 0; row < imageLength; ++row)
{
+#if G_BYTE_ORDER != G_LITTLE_ENDIAN
+ /* Make sure our channels are in the right order */
+ uint32 i;
+ for (i = 0; i < imageWidth; i++)
+ buffer[i + row * imageWidth] = GUINT32_TO_LE (buffer[i + row * imageWidth]);
+#endif
gimp_pixel_rgn_set_rect (&(channel[0].pixel_rgn),
channel[0].pixels + row * imageWidth * 4,
0, imageLength -row -1, imageWidth, 1);