diff options
author | Kari Salminen | 2009-03-28 16:07:56 +0000 |
---|---|---|
committer | Kari Salminen | 2009-03-28 16:07:56 +0000 |
commit | adbcfabcb1148009ab266b38c09275f6b01ba199 (patch) | |
tree | 240f45a568f687feba8b6599d2d598e28018ea45 | |
parent | 329c3321e8eb62ce7b73daa41c4bed3e0880a452 (diff) | |
download | scummvm-rg350-adbcfabcb1148009ab266b38c09275f6b01ba199.tar.gz scummvm-rg350-adbcfabcb1148009ab266b38c09275f6b01ba199.tar.bz2 scummvm-rg350-adbcfabcb1148009ab266b38c09275f6b01ba199.zip |
Cine::Palette: Add empty() and isValid() functions.
svn-id: r39725
-rw-r--r-- | engines/cine/pal.cpp | 11 | ||||
-rw-r--r-- | engines/cine/pal.h | 4 |
2 files changed, 15 insertions, 0 deletions
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; |