aboutsummaryrefslogtreecommitdiff
path: root/graphics/pixelformat.h
diff options
context:
space:
mode:
authorKari Salminen2009-03-27 20:56:15 +0000
committerKari Salminen2009-03-27 20:56:15 +0000
commitd85e3b72d24998e52030b602b86b2b0a09138a9b (patch)
tree2bbb64e580abe049fa65a8056bdb5a8d46c3a876 /graphics/pixelformat.h
parent80ab6ccf441914c2cecacf6a53c74a6db5379e6a (diff)
downloadscummvm-rg350-d85e3b72d24998e52030b602b86b2b0a09138a9b.tar.gz
scummvm-rg350-d85e3b72d24998e52030b602b86b2b0a09138a9b.tar.bz2
scummvm-rg350-d85e3b72d24998e52030b602b86b2b0a09138a9b.zip
Add color component bit count (rBits, gBits, bBits, aBits) and maximum value (rMax, gMax, bMax, aMax) convenience functions to PixelFormat-struct (If someone objects to adding these, holler and/or revert this commit, I can live without 'em but they'd ease some parts of Cine::Palette-code).
svn-id: r39711
Diffstat (limited to 'graphics/pixelformat.h')
-rw-r--r--graphics/pixelformat.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/graphics/pixelformat.h b/graphics/pixelformat.h
index 733499839b..7015f4d66f 100644
--- a/graphics/pixelformat.h
+++ b/graphics/pixelformat.h
@@ -86,6 +86,46 @@ struct PixelFormat {
g = ((color >> gShift) << gLoss) & 0xFF;
b = ((color >> bShift) << bLoss) & 0xFF;
}
+
+ //////////////////////////////////////////////////////////////////////
+ // Convenience functions for getting number of color component bits //
+ //////////////////////////////////////////////////////////////////////
+
+ inline byte rBits() const {
+ return (8 - rLoss);
+ }
+
+ inline byte gBits() const {
+ return (8 - gLoss);
+ }
+
+ inline byte bBits() const {
+ return (8 - bLoss);
+ }
+
+ inline byte aBits() const {
+ return (8 - aLoss);
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ // Convenience functions for getting color components' maximum values //
+ ////////////////////////////////////////////////////////////////////////
+
+ inline uint rMax() const {
+ return (1 << rBits()) - 1;
+ }
+
+ inline uint gMax() const {
+ return (1 << gBits()) - 1;
+ }
+
+ inline uint bMax() const {
+ return (1 << bBits()) - 1;
+ }
+
+ inline uint aMax() const {
+ return (1 << aBits()) - 1;
+ }
};
} // end of namespace Graphics