Skip to content

PyGame may load palette .png incorrectly, which breaks ngdevkit tools #96

@dciabrin

Description

@dciabrin

tiletool / paltool rely on PyGame (which relies on SDL_image) to load input images transparently, without having to care about the image file format. Currently, it expects a palette-based image but works equally well with palette-based png or gif images.

However recent version of SDL_image added support for stb_image as way to load .png files (instead of libpng), and std_image always returns a true-color surface to PyGame, as explained in their code:

// Paletted PNG, BMP, GIF, and PIC images are automatically depalettized.

This breaks tiletool / paltool as this mangles the pixel information from the file, and it removes the palette information from the SDL surface.

Consequently, PyGame returns different information to tiletool / paltool depending on how SDL_image is compiled (with or without stb_image). This is confusing and can't be easily avoided.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions