Optiroc / SuperFamiconv

Flexible and composable tile graphics converter supporting Super Nintendo, Game Boy, Game Boy Color, Game Boy Advance, Mega Drive, PC Engine and WonderSwan formats.
MIT License
152 stars 22 forks source link

Errors when using no remap, json palettes and 2 BPP mode #27

Open est77 opened 3 years ago

est77 commented 3 years ago

In the code here: https://github.com/Optiroc/SuperFamiconv/blob/master/src/Palette.cpp#L93, this check seems wrong when using 2 BPP or more that 1 palette. If the check fails, SuperFamiconv throws an exception and enters the catch block and tries to read the json palette as a binary palette with pretty random results.

In my case, I have a 16 colors palette in the original image that I expect SuperFamiconv to convert to 4 palettes with 4 colors each in 2 bpp mode. The check fails because 16 colors is greater than 4.

Using native binary palettes instead seems to work ok.

Optiroc commented 3 years ago

Do you have sample JSON input to test with?

est77 commented 3 years ago

Attached the original PNG image and json palette.

hud

hud_pal.json.txt

superfamiconv command:

superfamiconv tiles -i hud.png -p hud_pal.json -d hud_tileset.chr -B 2 -W 8 -H 8 -v -D -F