Use a constant for 0x8001 (#1596)

This commit is contained in:
Rangi
2025-01-04 04:03:40 -05:00
committed by GitHub
parent d9773424e4
commit b13c0f2f8e
3 changed files with 7 additions and 4 deletions

View File

@@ -10,6 +10,10 @@
#include "gfx/rgba.hpp" #include "gfx/rgba.hpp"
// Allow a slot for every possible CGB color, plus one for transparency
// 32 (1 << 5) per channel, times 3 RGB channels = 32768 CGB colors
static constexpr size_t NB_COLOR_SLOTS = (1 << (5 * 3)) + 1;
struct Palette; struct Palette;
void sortIndexed( void sortIndexed(
@@ -20,7 +24,7 @@ void sortIndexed(
png_byte *palAlpha png_byte *palAlpha
); );
void sortGrayscale( void sortGrayscale(
std::vector<Palette> &palettes, std::array<std::optional<Rgba>, 0x8001> const &colors std::vector<Palette> &palettes, std::array<std::optional<Rgba>, NB_COLOR_SLOTS> const &colors
); );
void sortRgb(std::vector<Palette> &palettes); void sortRgb(std::vector<Palette> &palettes);

View File

@@ -46,7 +46,7 @@ void sortIndexed(
} }
void sortGrayscale( void sortGrayscale(
std::vector<Palette> &palettes, std::array<std::optional<Rgba>, 0x8001> const &colors std::vector<Palette> &palettes, std::array<std::optional<Rgba>, NB_COLOR_SLOTS> const &colors
) { ) {
options.verbosePrint(Options::VERB_LOG_ACT, "Sorting palette by grayscale bins...\n"); options.verbosePrint(Options::VERB_LOG_ACT, "Sorting palette by grayscale bins...\n");

View File

@@ -26,8 +26,7 @@
#include "gfx/proto_palette.hpp" #include "gfx/proto_palette.hpp"
class ImagePalette { class ImagePalette {
// Use as many slots as there are CGB colors (plus transparency) std::array<std::optional<Rgba>, NB_COLOR_SLOTS> _colors;
std::array<std::optional<Rgba>, 0x8001> _colors;
public: public:
ImagePalette() = default; ImagePalette() = default;