aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorKari Salminen2009-03-27 21:31:03 +0000
committerKari Salminen2009-03-27 21:31:03 +0000
commitce414e66719161461367f6ec065f61b1ac42248a (patch)
treee41facb26a34749fda1a7e0529e66e5f00eeb51c /engines
parent6ef983335e527e2747b445e59579553f033c4d3f (diff)
downloadscummvm-rg350-ce414e66719161461367f6ec065f61b1ac42248a.tar.gz
scummvm-rg350-ce414e66719161461367f6ec065f61b1ac42248a.tar.bz2
scummvm-rg350-ce414e66719161461367f6ec065f61b1ac42248a.zip
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
Diffstat (limited to 'engines')
-rw-r--r--engines/cine/pal.cpp11
-rw-r--r--engines/cine/pal.h11
2 files changed, 22 insertions, 0 deletions
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