Allow fewer tRNS entries than PLTE colors (#1284)

This commit is contained in:
Rangi
2023-12-31 06:47:53 -05:00
committed by GitHub
parent 528a4c0b70
commit b0f2f0ffd6
7 changed files with 17 additions and 15 deletions

View File

@@ -14,12 +14,12 @@
namespace sorting {
void indexed(std::vector<Palette> &palettes, int palSize, png_color const *palRGB,
png_byte *palAlpha) {
int palAlphaSize, png_byte *palAlpha) {
options.verbosePrint(Options::VERB_LOG_ACT, "Sorting palettes using embedded palette...\n");
auto pngToRgb = [&palRGB, &palAlpha](int index) {
auto pngToRgb = [&palRGB, &palAlphaSize, &palAlpha](int index) {
auto const &c = palRGB[index];
return Rgba(c.red, c.green, c.blue, palAlpha ? palAlpha[index] : 0xFF);
return Rgba(c.red, c.green, c.blue, palAlpha && index < palAlphaSize ? palAlpha[index] : 0xFF);
};
for (Palette &pal : palettes) {