[Image-SIG] Re: bug in getcolors()
Fredrik Lundh
fredrik at pythonware.com
Thu Feb 17 22:16:08 CET 2005
Richard Oudkerk wrote:
> Sometimes (depending on the setting of the parameter maxcolors) the
> last colour in the list returned by im.getcolors() is reported as
> having a zero pixel count, and that colour will have appeared earlier
> in the list.
> This seems to be caused by a bug at the end of getcolors32() in
> GetBBox.c when table[] is being packed.
>
> It looks as though the packing only works correctly if table[0] is
> unoccupied (or the image has only one colour). Otherwise table[0]
> will get overwritten and lost.
tricky.
after staring at the code for a while, I'm pretty sure it was supposed
to look like this:
/* pack the table */
for (x = y = 0; x < (int) code_size; x++)
if (table[x].count) {
if (x != y)
table[y] = table[x];
y++;
}
table[y].count = 0; /* mark end of table */
thanks /F
More information about the Image-SIG
mailing list