From 2732ed3dcec40664a988c6ca43fff7996781624e Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 17 Apr 2006 11:09:21 +0000 Subject: Fixed (A)RGBToColor templates svn-id: r21969 --- graphics/colormasks.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'graphics/colormasks.h') diff --git a/graphics/colormasks.h b/graphics/colormasks.h index 06a791c50d..16ebafc020 100644 --- a/graphics/colormasks.h +++ b/graphics/colormasks.h @@ -220,17 +220,17 @@ struct ColorMasks<8888> { template uint32 RGBToColor(uint8 r, uint8 g, uint8 b) { return T::kAlphaMask | - ((r << T::kRedShift) & T::kRedMask) | - ((g << T::kGreenShift) & T::kGreenMask) | - ((b << T::kBlueShift) & T::kBlueMask); + (((r << T::kRedShift) >> (8 - T::kRedBits)) & T::kRedMask) | + (((g << T::kGreenShift) >> (8 - T::kGreenBits)) & T::kGreenMask) | + (((b << T::kBlueShift) >> (8 - T::kBlueBits)) & T::kBlueMask); } template 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); + return (((a << T::kAlphaShift) >> (8 - T::kAlphaBits)) & T::kAlphaMask) | + (((r << T::kRedShift) >> (8 - T::kRedBits)) & T::kRedMask) | + (((g << T::kGreenShift) >> (8 - T::kGreenBits)) & T::kGreenMask) | + (((b << T::kBlueShift) >> (8 - T::kBlueBits)) & T::kBlueMask); } template -- cgit v1.2.3