Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with a dual-palette image #23

Open
sverx opened this issue Nov 17, 2021 · 2 comments
Open

problem with a dual-palette image #23

sverx opened this issue Nov 17, 2021 · 2 comments

Comments

@sverx
Copy link
Contributor

sverx commented Nov 17, 2021

I created two separate 16 colors images, latest BMP2Tile can process them correctly.

p1:
p1

p2:
p2

but once I create a single image joining the two parts:
p

BMP2Tile complains
Error: Image uses colors from both palettes
though the image is technically correct. ☹️

@maxim-zhao
Copy link
Owner

In the images as posted - which have maybe been "optimised" by GitHub - both halves use colours in both the first and second 16 colours. Can you maybe attach the data in a zip? I don't have a way to create the test image from the two halves myself.

The code in BMP2Tile works by, for each 8x8 tile, checking if either all the colours are in the range 0..15 or in the range 16..31. If neither is true then you get the error. This also means that if you have two tiles that use identical tile indices with the two palettes, they can be de-duped to a single tile. Here's my test image, with the palette shown:

Image

This is correctly de-duped to two tiles, and a tilemap of

.dw $0000 $0001
.dw $0800 $0801

...i.e. the lower row is the upper row with the sprite palette.

@sverx
Copy link
Contributor Author

sverx commented Mar 14, 2025

I see your point - it's all about what one defines a dual-paletted image to be.

One simple definition could be an image that uses 17≤N≤32 palette entries where each tile uses either palette entries 0..15 or entries 16..N and they'll be using the palette # that matches their set. It's what you already have.

A better definition could be an image that uses 17≤N≤32 palette entries where each tile uses either entries 0..15 (these would be tiles using palette 0) or a mix of the entries 0..15 and 16..N, provided that after N there's enough space in the second palette to duplicate the used entries from the first palette. In this case the source image isn't natively dual-paletted but it's made in a way that respect the constraints required by the system.

The best definition would be any image that uses 17≤N≤32 palette entries where each tile uses one of two subsets of at most 16 entries from the image palette. This still respect the constraints required by the system, and the image I posted above is of this kind: it uses less than 16 colors for each part and there are few colors that are used by both parts so the tool I used to put together the two 16-colors image had created a single palette that resulted in the union of the two parts palettes.

Of course you can choose to support a definition according to what you personally prefer or to the extent you can be bothered to code it. It's a nice addition but not something the program would be useless if missing it. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants