[Scummvm-cvs-logs] SF.net SVN: scummvm:[39711] scummvm/trunk/graphics/pixelformat.h

buddha_ at users.sourceforge.net buddha_ at users.sourceforge.net
Fri Mar 27 21:56:15 CET 2009


Revision: 39711
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39711&view=rev
Author:   buddha_
Date:     2009-03-27 20:56:15 +0000 (Fri, 27 Mar 2009)

Log Message:
-----------
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).

Modified Paths:
--------------
    scummvm/trunk/graphics/pixelformat.h

Modified: scummvm/trunk/graphics/pixelformat.h
===================================================================
--- scummvm/trunk/graphics/pixelformat.h	2009-03-27 20:03:38 UTC (rev 39710)
+++ scummvm/trunk/graphics/pixelformat.h	2009-03-27 20:56:15 UTC (rev 39711)
@@ -86,6 +86,46 @@
 		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


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list