pygame-community / pygame-ce

🐍🎮 pygame - Community Edition is a FOSS Python library for multimedia applications (like games). Built on top of the excellent SDL library.
https://pyga.me
849 stars 140 forks source link

expose low-level colorkey info #2841

Open robertpfeiffer opened 5 months ago

robertpfeiffer commented 4 months ago

My goal with this branch was to implement a different kind of converting for indexed surfaces, but at this point I am content to just have this so I can handle converted surfaces this way. If you need to know why this is exposed, it's because the PNG loading in SDL_image can load a palette with two identical colours and assign the correct one as the colour key.

I have encountered this behaviour in one of my games already, it's annoying.

I wanted to have a "reverse convert" to convert an 8-bit surface for receiving blits from indexed surfaces. Then I could convert all surfaces to the same palette and color key. Unfortunately, this doesn't work 100% reliably, at least not without assumptions about the palette the png file was saved with, and the palette SDL_image constructs when loading an indexed png.

robertpfeiffer commented 4 months ago

Anyway, it is probably better to expose this so I can write my palette-normaliser in python than to implement the palette-normaliser in C. I should probably check if it's actually faster to do it this way than just 32bit RGBA.

robertpfeiffer commented 3 months ago

Okay. I'll change the name, fix the check for the return value, and update the docs.