This may or may not be relevant, but notice that 41+86=128.

[bin(x) for x in [0, 41, 86, 127]]
[0b0, 0b101001, 0b1010110, 0b1111111]

Russell

On 19 February 2012 17:00, Erik Grahn J. <eri...@gmail.com> wrote:

> Hey all,
>
> I'm writing something where I load 4-colour indexed PNG images (8x8 tiles)
> with a simple greyscale palette (four entries, in order: black, dark grey,
> light grey, white) off disk. I then intend to recolour these in different
> ways by replacing the palette indices using PixelArray.replace, but I'm
> kind of getting stuck because I'm not getting the palette values I want
> from the file.
>
> In the 8-bit PNG, my four greyscale colours are unquestionably palette
> indices 0-3 (I have verified this with a hex editor even, they are the
> first four values in the PLTE chunk) but when I turn my surface into a
> PixelArray and print it, it looks like this:
>
>        PixelArray(
>          [0, 0, 86, 127, 127, 0, 0, 0]
>          [0, 86, 127, 86, 86, 86, 0, 0]
>          [86, 127, 86, 86, 41, 86, 86, 0]
>          [86, 127, 86, 86, 41, 86, 86, 0]
>          [86, 127, 86, 86, 41, 86, 86, 0]
>          [86, 127, 86, 41, 41, 86, 86, 0]
>          [0, 86, 127, 86, 86, 86, 0, 0]
>          [0, 0, 86, 86, 86, 0, 0, 0]
>        )
>
> So instead of the values I want (0, 1, 2, 3), I'm getting 0, 41, 86 and
> 127. I have no idea where it gets these numbers from. Possibly a conversion
> to some internal default palette somewhere? I have tried calling
> set_palette on the surface to no avail -- same results.
>
> Any help would be super appreciated.
>
>
> --
> Erik Grahn J. <eri...@gmail.com>
>

Reply via email to