There are gif files that use a subset of the original color map remapping
used entries into first indexes. E.g. the main palette contains 256 colors,
but then a frame can use 4-bit per pixel to reference 16 colors from the
original 256 color palette.
When we converted an Indexed image to RGB, the original sprite
transparent color was being kept but the mask color of all its images
was reset to 0. With this change we kept the same mask color on all images
to avoid an assert() in the render code.
Anyway the whole RGB <-> Indexed conversion should be reviewed in these
cases. I think there are some situation where a transparent color = 0 is
expected in RGB sprites (as we shouldn't be able to change the transparent
color of an RGB sprite).
Saving a file with v1.1, loading it with v1.0, and then loading it back
with v1.1 was generating a layer with flag 32 enabled ("layer has opacity
bit") and opacity = 0 (the opacity was overwritten by v1.0, but the flag
was persisted).
Now the "layers have opacity" bit is saved in the file header. This
flag can be used because v1.0 saves it with value = 0.
With this change we save the new palette chunk when it's necessary, and
the old color2 chunk will be always present only for backward
compatibility. (So we can open a .ase file saved with v1.1 in v1.0.)
In this way the default palette can contain colors with alpha channel.
Also, we migrate the old .gpl to .ase format, removing extra black entries
in the default palette (the old format contains 256 colors, and now we
can handle less colors).
Instead of calling findBestfit() for all RGBA colors in
RgbMap::regenerate(), we mark all entries as invalid, and then we
validate them only when the user require one specific entry from
RgbMap::mapColor(). With this we avoid a lot of unnecessary computations
each time the palette changes.
Now that we have alpha channel in color selector and palette entries, it's
nice to have as a default ink a more pixel-art friendly, i.e.
an ink that just replace RGBA values instead of doing alpha compositing.
Issue #286
This include several changes:
- Color::getIndex() can return palette values with alpha != 255
- Fix Transparent and Blurs ink for indexed images to make better use
of palette entries with alpha values
- Fix bilinear resize algorithm for indexed images with alpha
- New RgbMap with four parameters: R, G, B, A
- Add one extra color scale function used in the alpha channel of the
new RgbMap
- Fix color curve, convolution matrix, invert color, and median filters
to take care of this new alpha channel on indexed images
- Fix ordered dithering and quantization
Related to #286