diff --git a/include/gfx/pal_sorting.hpp b/include/gfx/pal_sorting.hpp index a9f27985..4d1015d3 100644 --- a/include/gfx/pal_sorting.hpp +++ b/include/gfx/pal_sorting.hpp @@ -10,6 +10,10 @@ #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; void sortIndexed( @@ -20,7 +24,7 @@ void sortIndexed( png_byte *palAlpha ); void sortGrayscale( - std::vector &palettes, std::array, 0x8001> const &colors + std::vector &palettes, std::array, NB_COLOR_SLOTS> const &colors ); void sortRgb(std::vector &palettes); diff --git a/src/gfx/pal_sorting.cpp b/src/gfx/pal_sorting.cpp index d78b4f9b..0cfde25a 100644 --- a/src/gfx/pal_sorting.cpp +++ b/src/gfx/pal_sorting.cpp @@ -46,7 +46,7 @@ void sortIndexed( } void sortGrayscale( - std::vector &palettes, std::array, 0x8001> const &colors + std::vector &palettes, std::array, NB_COLOR_SLOTS> const &colors ) { options.verbosePrint(Options::VERB_LOG_ACT, "Sorting palette by grayscale bins...\n"); diff --git a/src/gfx/process.cpp b/src/gfx/process.cpp index 57b6906b..a80a5033 100644 --- a/src/gfx/process.cpp +++ b/src/gfx/process.cpp @@ -26,8 +26,7 @@ #include "gfx/proto_palette.hpp" class ImagePalette { - // Use as many slots as there are CGB colors (plus transparency) - std::array, 0x8001> _colors; + std::array, NB_COLOR_SLOTS> _colors; public: ImagePalette() = default;