Skip to content

Commit

Permalink
Use a constant for 0x8001 (#1596)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 authored Jan 4, 2025
1 parent d977342 commit b13c0f2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 5 additions & 1 deletion include/gfx/pal_sorting.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -20,7 +24,7 @@ void sortIndexed(
png_byte *palAlpha
);
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);

Expand Down
2 changes: 1 addition & 1 deletion src/gfx/pal_sorting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void sortIndexed(
}

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");

Expand Down
3 changes: 1 addition & 2 deletions src/gfx/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
#include "gfx/proto_palette.hpp"

class ImagePalette {
// Use as many slots as there are CGB colors (plus transparency)
std::array<std::optional<Rgba>, 0x8001> _colors;
std::array<std::optional<Rgba>, NB_COLOR_SLOTS> _colors;

public:
ImagePalette() = default;
Expand Down

0 comments on commit b13c0f2

Please sign in to comment.