diff options
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/pixelformat.h | 40 |
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 |