mirror of
https://github.com/gbdev/rgbds.git
synced 2026-09-18 19:57:06 +00:00
Fix handling of PNG files with RGB or RGBA color type that have a PLTE chunk
This commit is contained in:
@@ -33,7 +33,13 @@ void sortIndexed(std::vector<Palette> &palettes, std::vector<Rgba> const &embPal
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unreachable_(); // LCOV_EXCL_LINE
|
// A PNG image using PNG_COLOR_TYPE_RGB (2) or PNG_COLOR_TYPE_RGBA (6) can still
|
||||||
|
// contain a PLTE chunk. From the PNG spec: "If present, it provides a suggested set of
|
||||||
|
// from 1 to 256 colors to which the truecolor image can be quantized if the viewer
|
||||||
|
// cannot display truecolor directly." This means that an input image may have pixels
|
||||||
|
// with colors that are not in the PLTE chunk, so iterating through `embPal` may finish
|
||||||
|
// without returning. In that case, we compare `lhs` and `rhs` directly.
|
||||||
|
return lhs < rhs;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 99 B |
Reference in New Issue
Block a user