Add compatibility hack for unused colors in indexed PNGs

This commit is contained in:
ISSOtm
2022-03-09 00:00:07 +01:00
committed by Eldred Habert
parent b95c26c886
commit 20442c8a43
5 changed files with 43 additions and 25 deletions

View File

@@ -374,7 +374,7 @@ void Palette::addColor(uint16_t color) {
}
uint8_t Palette::indexOf(uint16_t color) const {
return std::distance(colors.begin(), std::find(colors.begin(), colors.end(), color));
return std::find(colors.begin(), colors.end(), color) - colors.begin();
}
auto Palette::begin() -> decltype(colors)::iterator {
@@ -390,3 +390,7 @@ auto Palette::begin() const -> decltype(colors)::const_iterator {
auto Palette::end() const -> decltype(colors)::const_iterator {
return std::find(colors.begin(), colors.end(), UINT16_MAX);
}
uint8_t Palette::size() const {
return indexOf(UINT16_MAX);
}