[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Pygame blitting 8-bit surfaces doesn't ignore palettes?



Brian Madden wrote:
I'm seeing that that when blitting, Pygame will use the source surface's palette to get the 24-bit entry for each pixel, then look for that 24-bit value in the destination surface's palette, and then write the 8-bit integer value from the destination surface's palette as the pixel value in the destination surface.

I'm just curious as to whether this is this a bug, or is my understanding of how Pygame works with 8-bit surfaces not correct?

This behaviour is probably more or less what one wants most of the
time, so I'd say the bug, if any, is in the docs. ("More or less"
because it would be less surprising to use the nearest colour from
the destination palette if there isn't an exact match.)

> I have multiple surfaces each with their own palettes, and if I
blit a pixel value of "1" then I want it to be "1" on my destination surface regardless of what any of the palettes are! :)

I haven't tried it, but if the docs are to be believed, you should
be able to get this effect by creating a subsurface referencing the
original source surface, setting its palette to be the same as the
destination palette, and then blitting from that.

You might also be able to do something with surfarrays, but I'm
not sure.

--
Greg