From adbcfabcb1148009ab266b38c09275f6b01ba199 Mon Sep 17 00:00:00 2001 From: Kari Salminen Date: Sat, 28 Mar 2009 16:07:56 +0000 Subject: Cine::Palette: Add empty() and isValid() functions. svn-id: r39725 --- engines/cine/pal.cpp | 11 +++++++++++ engines/cine/pal.h | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/engines/cine/pal.cpp b/engines/cine/pal.cpp index 94c0f59dc0..3341da39c5 100644 --- a/engines/cine/pal.cpp +++ b/engines/cine/pal.cpp @@ -208,6 +208,10 @@ Palette &Palette::rotateRight(byte firstIndex, byte lastIndex) { return *this; } +bool Palette::empty() const { + return _colors.empty(); +} + uint Palette::colorCount() const { return _colors.size(); } @@ -222,6 +226,13 @@ Palette &Palette::fillWithBlack() { return *this; } +// TODO: Add better heuristic for checking whether the color format is valid +bool Palette::isValid() const { + // Check that the color format has been actually set and not just default constructed. + // Also check that the alpha channel is discarded. + return _format != Graphics::PixelFormat() && _format.aLoss == 8; +} + Graphics::PixelFormat Palette::colorFormat() const { return _format; } diff --git a/engines/cine/pal.h b/engines/cine/pal.h index 1f55a4f73f..f63073763c 100644 --- a/engines/cine/pal.h +++ b/engines/cine/pal.h @@ -139,10 +139,14 @@ public: */ Palette &saturatedAddNormalizedGray(Palette& output, byte firstIndex, byte lastIndex, signed grayDividend, signed grayDenominator); + bool empty() const; uint colorCount() const; Palette &fillWithBlack(); + /*! \brief Is the palette valid? (Mostly just checks the color format for correctness) */ + bool isValid() const; + /*! \brief The original color format in which this palette was loaded. */ Graphics::PixelFormat colorFormat() const; -- cgit v1.2.3