diff --git a/src/raster/palette.cpp b/src/raster/palette.cpp index 29d9a3032..ed0ecbdb8 100644 --- a/src/raster/palette.cpp +++ b/src/raster/palette.cpp @@ -34,7 +34,7 @@ using namespace gfx; Palette::Palette(int frame, int ncolors) : GfxObj(GFXOBJ_PALETTE) { - ASSERT(ncolors >= 1 && ncolors <= 256); + ASSERT(ncolors >= 1 && ncolors <= MaxColors); m_frame = frame; m_colors.resize(ncolors); @@ -57,15 +57,15 @@ Palette::~Palette() Palette* Palette::createGrayscale() { - Palette* graypal = new Palette(0, 256); - for (int c=0; c<256; c++) + Palette* graypal = new Palette(0, MaxColors); + for (int c=0; csetEntry(c, _rgba(c, c, c, 255)); return graypal; } void Palette::resize(int ncolors) { - ASSERT(ncolors >= 1 && ncolors <= 256); + ASSERT(ncolors >= 1 && ncolors <= MaxColors); int old_size = m_colors.size(); m_colors.resize(ncolors); @@ -186,7 +186,7 @@ void Palette::makeVertRamp(int from, int to, int columns) ASSERT(from >= 0 && from <= 255); ASSERT(to >= 0 && to <= 255); - ASSERT(columns >= 1 && columns <= 256); + ASSERT(columns >= 1 && columns <= MaxColors); /* both indices have to be in the same column */ ASSERT((from % columns) == (to % columns)); @@ -224,7 +224,7 @@ void Palette::makeRectRamp(int from, int to, int columns) ASSERT(from >= 0 && from <= 255); ASSERT(to >= 0 && to <= 255); - ASSERT(columns >= 1 && columns <= 256); + ASSERT(columns >= 1 && columns <= MaxColors); if (from > to) std::swap(from, to); @@ -379,8 +379,8 @@ void Palette::sort(int from, int to, SortPalette* sort_palette, std::vector std::sort(temp.begin(), temp.end(), PalEntryWithIndexPredicate(sort_palette)); // Default mapping table (no-mapping) - mapping.resize(256); - for (int i=0; i<256; ++i) + mapping.resize(MaxColors); + for (int i=0; ifromAllegro(rgbpal); } } diff --git a/src/raster/palette.h b/src/raster/palette.h index d265621ee..458e051f9 100644 --- a/src/raster/palette.h +++ b/src/raster/palette.h @@ -53,6 +53,8 @@ private: class Palette : public GfxObj { public: + enum { MaxColors = 256 }; + Palette(int frame, int ncolors); Palette(const Palette& palette); ~Palette();