Description
rgbgfx
must generate palettes from the colors in the input image, unless-c
was used; in that case, the provided palettes will be used.If the PNG file internally contains a palette (often dubbed an “indexed” PNG), then colors in each output palette will be sorted according to their order in the PNG's palette.
Note that the “indexed” behavior depends on an internal detail of how the PNG is saved, specifically its ‘
PLTE
’ chunk. Since few image editors (such as GIMP) expose that detail, this behavior is only kept for compatibility and should be considered deprecated.
Currently some people have an indexed PNG with more than 4 colors, which only uses 4 of those colors. The legacy behavior of rgbgfx
is to use just the 4 colors that are actually used, but keep their order from the indexed palette.
The problem with this behavior is that it means identical-looking input images may not give identical output. If image A uses four shades of gray and is encoded as 2-bit grayscale, and image B is identical but uses an indexed 4-color palette (and you don't know the order because most image editors don't make that info available), then image B will have a different 2bpp encoding than you'd expect from the usual sort-by-darkness rule.
This behavior should be removed. The -c
flag is sufficient; users can specify the four colors they want, or edit their indexed palette to have just those colors.