[Scummvm-cvs-logs] SF.net SVN: scummvm: [21967] scummvm/trunk/graphics/colormasks.h
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Mon Apr 17 03:42:02 CEST 2006
Revision: 21967
Author: fingolfin
Date: 2006-04-17 03:41:18 -0700 (Mon, 17 Apr 2006)
ViewCVS: http://svn.sourceforge.net/scummvm/?rev=21967&view=rev
Log Message:
-----------
Add color conversion functions based on ColorMasks, to demonstrate how this would work
Modified Paths:
--------------
scummvm/trunk/graphics/colormasks.h
Modified: scummvm/trunk/graphics/colormasks.h
===================================================================
--- scummvm/trunk/graphics/colormasks.h 2006-04-17 10:22:05 UTC (rev 21966)
+++ scummvm/trunk/graphics/colormasks.h 2006-04-17 10:41:18 UTC (rev 21967)
@@ -217,5 +217,34 @@
};
};
+template<class T>
+uint32 RGBToColor(uint8 r, uint8 g, uint8 b) {
+ return ((r << T::kRedShift) & T::kRedMask) |
+ ((g << T::kGreenShift) & T::kGreenMask) |
+ ((b << T::kBlueShift) & T::kBlueMask);
+}
+template<class T>
+uint32 ARGBToColor(uint8 a, uint8 r, uint8 g, uint8 b) {
+ return ((a << T::kAlphaShift) & T::kAlphaMask) |
+ ((r << T::kRedShift) & T::kRedMask) |
+ ((g << T::kGreenShift) & T::kGreenMask) |
+ ((b << T::kBlueShift) & T::kBlueMask);
+}
+
+template<class T>
+void colorToRGB(uint32 color, uint8 &r, uint8 &g, uint8 &b) {
+ r = ((color & T::kRedMask) >> T::kRedShift) << (8 - T::kRedBits);
+ g = ((color & T::kGreenMask) >> T::kGreenShift) << (8 - T::kGreenBits);
+ b = ((color & T::kBlueMask) >> T::kBlueShift) << (8 - T::kBlueBits);
+}
+
+template<class T>
+void colorToARGB(uint32 color, uint8 &a, uint8 &r, uint8 &g, uint8 &b) {
+ a = ((color & T::kAlphaMask) >> T::kAlphaShift) << (8 - T::kAlphaBits);
+ r = ((color & T::kRedMask) >> T::kRedShift) << (8 - T::kRedBits);
+ g = ((color & T::kGreenMask) >> T::kGreenShift) << (8 - T::kGreenBits);
+ b = ((color & T::kBlueMask) >> T::kBlueShift) << (8 - T::kBlueBits);
+}
+
#endif
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