I've been adding functionality to grit for converting several images but only generating a single (optimised) palette file. It is the one feature that I miss from gfx2gba. Grit's current behaviour is to create a 256-entry palette for each image. I realise that -pw or -pe can create smaller palettes, but that is no help in this case. The global palette option is if various images share some of their colours, not necessarily all, and there are up to 16 or 256 unique colours in total.
Here are the tech details.. The main design problem I've had has been that the current overall grit processing works something like this:
Code: Select all
for filename in filenames
{
GRIT_REC record = new GRIT_REC(filename)
process(record)
}
Code: Select all
vector<GRIT_REC> grv;
for filename in filenames
{
GRIT_REC record = new GRIT_REC(filename)
grv.push_back( record );
process(record)
}
COLOR global_palette[256];
for record in grv
{
for color in record.palette
{
if color not in global_palette
{
add_to_global_palette(color);
}
replace_index(old_palette_index, new_palette_index);
}
}
output(global_palette);
output(records in grv);
I'm working on an NDS example or 2 as well, so I can test typical use cases.
Does that make sense to anyone? Is this something that would be of interest to people? I know I've used this a lot in the past. Oh, and is anyone working on adding this type of thing already? Wouldn't want to duplicate work, but I am *almost* done with it now.