[Image-SIG] PIL buglet?

Georg Mischler schorsch@schorsch.com
Tue, 21 Sep 1999 14:22:17 -0400 (EDT)


Hi all,

it looks as if I just found a tiny bug in PIL 1.0.

In Imaging.h, the ImagingMemoryInstance is defined as:

struct ImagingMemoryInstance {

    /* Format */
    char mode[4+1];	/* Band names ("1", "L", "P", "RGB", "RGBA", "CMYK") */
    int type;		/* Data type */
    int depth;		/* Depth (ignored in this version) */
    int bands;	
...

This allows for mode designators up to 4 characters in length.
Unfortunately, some of the modes implemented in Storage.c
have names of up to 6 characters, which may (or may not,
depending on your compiler) overwrite the type member.
Most of those modes (except YCbCr) are marked as experimental,
and I didn't use any of them. But finding stuff like this
is probably still a part of that experiment.

I had some strange interactions with tkImaging, which seemed
to depend on the layout of the ImagingMemoryInstance. This
surfaced on linux when I tried to add another member (which I
don't to anymore). If the new member was in the "wrong" position
within the struct, then the image would get displayed
completely garbled. Now I had another effect on Solaris 2.4,
which resulted in images displayed with a strong blue tint.
In this case, I had made no changes to ImagingMemoryInstance.

I don't know if those effects have in fact anything to do
with the above buglet, but once I changed the definition
to "char mode[8];" and recompiled, the solaris blues went
away immediately. There may be other hidden dependencies
that were resolved by the recompile (it would be nice, if
the Makefile in the top level Imaging directory would
use Imaging.h and libImaging.a as conditions!), so I
can't say for sure what caused my funny results.

But even so, another bug removed is still a Good Thing... ;)


Have fun!

-schorsch

-- 
Georg Mischler  --  simulation developper  --  schorsch at schorsch.com
+schorsch.com+  --  lighting design tools  --  http://www.schorsch.com/