Fix two RGBGFX bugs (#1671)

* Fix two RGBGFX bugs

* Fix clang-format idempotence

* Update src/gfx/rgba.cpp

Co-authored-by: Eldred Habert <me@eldred.fr>

---------

Co-authored-by: Eldred Habert <me@eldred.fr>
This commit is contained in:
Rangi
2025-04-24 09:39:14 -04:00
committed by GitHub
parent a72843748f
commit 2a5b9b5f98
19 changed files with 14 additions and 10 deletions

View File

@@ -58,6 +58,7 @@ uint16_t Rgba::cgbColor() const {
uint8_t Rgba::grayIndex() const {
assume(isGray());
// Convert from [0; 256[ to [0; maxOpaqueColors[
return static_cast<uint16_t>(255 - red) * options.maxOpaqueColors() / 256;
// Convert from 0..<256 to hasTransparentPixels..<nbColorsPerPal
// Note that `maxOpaqueColors()` already takes `hasTransparentPixels` into account
return (255 - red) * options.maxOpaqueColors() / 256 + options.hasTransparentPixels;
}