22 #ifndef GRAPHICS_PIXELFORMAT_H 23 #define GRAPHICS_PIXELFORMAT_H 25 #include "common/scummsys.h" 26 #include "common/str.h" 28 #include "graphics/colormasks.h" 48 static inline uint expand(uint value) {
55 static inline uint expand(uint value) {
56 return value ? 0xff : 0;
62 static inline uint expand(uint value) {
73 static inline uint expand(uint value) {
83 static inline uint expand(uint value) {
92 static inline uint expand(uint value) {
101 static inline uint expand(uint value) {
103 return (value << 2) |
110 static inline uint expand(uint value) {
112 return (value << 1) |
119 static inline uint expand(uint value) {
147 rLoss(0), gLoss(0), bLoss(0), aLoss(0),
148 rShift(0), gShift(0), bShift(0), aShift(0) {}
169 byte RBits, byte GBits, byte BBits, byte ABits,
170 byte RShift, byte GShift, byte BShift, byte AShift) :
171 bytesPerPixel(BytesPerPixel),
176 rShift((RBits == 0) ? 0 : RShift),
177 gShift((GBits == 0) ? 0 : GShift),
178 bShift((BBits == 0) ? 0 : BShift),
179 aShift((ABits == 0) ? 0 : AShift)
190 #ifdef SCUMM_BIG_ENDIAN 199 #ifdef SCUMM_BIG_ENDIAN 208 #ifdef SCUMM_BIG_ENDIAN 217 #ifdef SCUMM_BIG_ENDIAN 226 #ifdef SCUMM_BIG_ENDIAN 235 #ifdef SCUMM_BIG_ENDIAN 245 rLoss == fmt.rLoss &&
246 gLoss == fmt.gLoss &&
247 bLoss == fmt.bLoss &&
248 aLoss == fmt.
aLoss &&
249 rShift == fmt.rShift &&
250 gShift == fmt.gShift &&
251 bShift == fmt.bShift &&
257 return !(*
this == fmt);
263 ((0xFF >> aLoss) << aShift) |
264 (( r >> rLoss) << rShift) |
265 (( g >> gLoss) << gShift) |
266 (( b >> bLoss) << bShift);
270 inline uint32 RGBToColorT(uint8 r, uint8 g, uint8 b)
const {
271 return T::kAlphaMask |
272 (((r << T::kRedShift) >> (8 - T::kRedBits)) & T::kRedMask) |
273 (((g << T::kGreenShift) >> (8 - T::kGreenBits)) & T::kGreenMask) |
274 (((b << T::kBlueShift) >> (8 - T::kBlueBits)) & T::kBlueMask);
278 inline uint32
ARGBToColor(uint8 a, uint8 r, uint8 g, uint8 b)
const {
280 ((a >> aLoss) << aShift) |
281 ((r >> rLoss) << rShift) |
282 ((g >> gLoss) << gShift) |
283 ((b >> bLoss) << bShift);
287 inline uint32 ARGBToColorT(uint8 a, uint8 r, uint8 g, uint8 b)
const {
288 return (((a << T::kAlphaShift) >> (8 - T::kAlphaBits)) & T::kAlphaMask) |
289 (((r << T::kRedShift) >> (8 - T::kRedBits)) & T::kRedMask) |
290 (((g << T::kGreenShift) >> (8 - T::kGreenBits)) & T::kGreenMask) |
291 (((b << T::kBlueShift) >> (8 - T::kBlueBits)) & T::kBlueMask);
295 inline void colorToRGB(uint32 color, uint8 &r, uint8 &g, uint8 &b)
const {
296 r = expand(rBits(), color >> rShift);
297 g = expand(gBits(), color >> gShift);
298 b = expand(bBits(), color >> bShift);
302 inline void colorToRGBT(uint32 color, uint8 &r, uint8 &g, uint8 &b)
const {
303 r = ((color & T::kRedMask) >> T::kRedShift) << (8 - T::kRedBits);
304 g = ((color & T::kGreenMask) >> T::kGreenShift) << (8 - T::kGreenBits);
305 b = ((color & T::kBlueMask) >> T::kBlueShift) << (8 - T::kBlueBits);
309 inline void colorToARGB(uint32 color, uint8 &a, uint8 &r, uint8 &g, uint8 &b)
const {
310 a = (aBits() == 0) ? 0xFF : expand(aBits(), color >> aShift);
311 r = expand(rBits(), color >> rShift);
312 g = expand(gBits(), color >> gShift);
313 b = expand(bBits(), color >> bShift);
317 inline void colorToARGBT(uint32 color, uint8 &a, uint8 &r, uint8 &g, uint8 &b)
const {
318 a = ((color & T::kAlphaMask) >> T::kAlphaShift) << (8 - T::kAlphaBits);
319 r = ((color & T::kRedMask) >> T::kRedShift) << (8 - T::kRedBits);
320 g = ((color & T::kGreenMask) >> T::kGreenShift) << (8 - T::kGreenBits);
321 b = ((color & T::kBlueMask) >> T::kBlueShift) << (8 - T::kBlueBits);
361 return rBits() + gBits() + bBits() + aBits();
374 return (1 << rBits()) - 1;
381 return (1 << gBits()) - 1;
388 return (1 << bBits()) - 1;
395 return (1 << aBits()) - 1;
399 static inline uint
expand(uint bits, uint color) {
432 return bytesPerPixel == 1 && rShift == 0 && gShift == 0 && bShift == 0 && aShift == 0;
437 inline uint32 PixelFormat::RGBToColorT<ColorMasks<0> >(uint8 r, uint8 g, uint8 b)
const {
438 return RGBToColor(r, g, b);
442 inline uint32 PixelFormat::ARGBToColorT<ColorMasks<0> >(uint8 a, uint8 r, uint8 g, uint8 b)
const {
443 return ARGBToColor(a, r, g, b);
447 inline void PixelFormat::colorToRGBT<ColorMasks<0> >(uint32 color, uint8 &r, uint8 &g, uint8 &b)
const {
448 colorToRGB(color, r, g, b);
452 inline void PixelFormat::colorToARGBT<ColorMasks<0> >(uint32 color, uint8 &a, uint8 &r, uint8 &g, uint8 &b)
const {
453 colorToARGB(color, a, r, g, b);
460 template<
int bitFormat>
Definition: pixelformat.h:43
Definition: formatinfo.h:28
Definition: colormasks.h:30