From ce414e66719161461367f6ec065f61b1ac42248a Mon Sep 17 00:00:00 2001 From: Kari Salminen Date: Fri, 27 Mar 2009 21:31:03 +0000 Subject: Cine::Palette: Add a black palette constructor and a clear-function for clearing the palette of all data (Releases used memory etc). svn-id: r39713 --- engines/cine/pal.cpp | 11 +++++++++++ engines/cine/pal.h | 11 +++++++++++ 2 files changed, 22 insertions(+) (limited to 'engines') diff --git a/engines/cine/pal.cpp b/engines/cine/pal.cpp index ebefee84bc..94c0f59dc0 100644 --- a/engines/cine/pal.cpp +++ b/engines/cine/pal.cpp @@ -269,6 +269,17 @@ Cine::Palette::Color Palette::saturatedAddColor(Cine::Palette::Color baseColor, return result; } +Palette::Palette(const Graphics::PixelFormat format, const uint numColors) : _format(format), _colors() { + _colors.resize(numColors); + fillWithBlack(); +} + +Palette &Palette::clear() { + _format = Graphics::PixelFormat(); + _colors.clear(); + return *this; +} + Palette &Palette::load(const byte *buf, const uint size, const Graphics::PixelFormat format, const uint numColors, const EndianType endian) { assert(format.bytesPerPixel * numColors <= size); // Make sure there's enough input space assert(format.aLoss == 8); // No alpha diff --git a/engines/cine/pal.h b/engines/cine/pal.h index 42228c570e..1f55a4f73f 100644 --- a/engines/cine/pal.h +++ b/engines/cine/pal.h @@ -80,6 +80,17 @@ private: }; public: + /*! \brief Create an initially black palette with the given color format and number of colors. + * \param format Color format + * \param numColors Number of colors + */ + Palette(const Graphics::PixelFormat format, const uint numColors); + + /*! \brief Clear the palette (Set color count to zero, release memory, overwrite color format with default value). + * \note This is very different from using fillWithBlack-function which fills the palette with black. + */ + Palette &clear(); + /*! \brief Load palette from buffer with given color format, endianness and number of colors. * \param buf Input buffer * \param size Input buffer size in bytes -- cgit v1.2.3