mapeditor / tiled

Flexible level editor
https://www.mapeditor.org/
Other
11.26k stars 1.76k forks source link

tmxrasterizer: option to keep color type and/or palette of PNGs #4007

Open basxto opened 4 months ago

basxto commented 4 months ago

Is your feature request related to a problem? Please describe. I use indexed PNGs (color type 3), which is handy for pixel art. Tiled always converts them to true color PNG, which is bigger. Tiled uses RGBA, which is 32bit per pixel, whereas 256 color indexed PNG only has 8bit per pixel. (bpp prior to compression)

There are indeed some difficulties. The tilesets could have different palettes, though it’s straight forward if all tilesets use the same palette. If they are different they could be merged or conversion be refused. Merging would lead to lower file sizes, but it would have no benefit for the following use cases.

I have multiple palettes, which I use with my tilesets. If tiled kept the color type and palette intact, I could open the exported map and switch palettes. Gimp, Grafx2 and mtPaint allow to load different palettes. This again allows to test a map with multiple palettes quickly instead of loading palette, saving the image, switching to tiled, loading the next palette etc.

Furthermore these exports would become usable on retro gaming platforms that use indexed images. (ZX Spectrum, NES, Game Boy etc.) For these platforms it’s important that the indexes are correct since image and palette get loaded separately. Furthermore there are tools who can create tile maps from a tileset PNG and tile map PNG. The twist with this is that they can optimize for hardware capabilities like Y-flip, X-flip etc, which might not be reflected in the tiled map if the map is for multiple platforms.

Another use case is to possibly create an animated GIF where frames share a palette instead of using per frame palettes. APNG always shares the palette between all frames if it’s indexed.

Describe the solution you'd like Flags like --nc and --np to not meddle with color type and/or palette when exporting to PNG. Could be different flags, that’s just how it’s named in oxipng and optipng.

Describe alternatives you've considered Writing my own tmx parser/exporter.