mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user