From c1ea105142e54948c86c03d756aa9dbd3fa7e0b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Wed, 6 Jul 2005 01:41:43 +0000 Subject: [PATCH] added alpha support for pixel types and stuff in order to support B_TRANSPARENT_MAGIC_CMAP8 in the system palette... might need review, maybe there is a smarter way. The 0xff entry in the palette has alpha = 0 now git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13472 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Bitmap.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/kits/interface/Bitmap.cpp b/src/kits/interface/Bitmap.cpp index d8bdd4dee8..d5051874a7 100644 --- a/src/kits/interface/Bitmap.cpp +++ b/src/kits/interface/Bitmap.cpp @@ -118,7 +118,7 @@ const rgb_color kSystemPalette[] = { { 51, 0, 51, 255 }, { 51, 0, 0, 255 }, { 255, 203, 51, 255 }, { 255, 203, 0, 255 }, { 255, 255, 0, 255 }, { 255, 255, 51, 255 }, { 255, 255, 102, 255 }, { 255, 255, 152, 255 }, { 255, 255, 203, 255 }, - { 255, 255, 255, 255 } + { 255, 255, 255, 0 } // B_TRANSPARENT_MAGIC_CMAP8 }; @@ -288,7 +288,7 @@ public: inline uint16 RGB16ColorForIndex(uint8 index) const; inline uint32 RGB24ColorForIndex(uint8 index) const; inline void RGB24ColorForIndex(uint8 index, uint8 &red, uint8 &green, - uint8 &blue) const; + uint8 &blue, uint8 &alpha) const; inline uint8 GrayColorForIndex(uint8 index) const; private: @@ -612,7 +612,7 @@ uint32 PaletteConverter::RGB24ColorForIndex(uint8 index) const { const rgb_color &color = fColorMap->color_list[index]; - return (color.red << 24) | (color.green << 16) | (color.blue >> 8); + return (color.blue << 24) | (color.red << 8) | (color.green << 16) | color.alpha; } // RGB24ColorForIndex @@ -631,12 +631,13 @@ PaletteConverter::RGB24ColorForIndex(uint8 index) const inline void PaletteConverter::RGB24ColorForIndex(uint8 index, uint8 &red, uint8 &green, - uint8 &blue) const + uint8 &blue, uint8 &alpha) const { const rgb_color &color = fColorMap->color_list[index]; red = color.red; green = color.green; blue = color.blue; + alpha = color.alpha; } // GrayColorForIndex @@ -1035,6 +1036,7 @@ struct rgb_color_value { uint8 red; uint8 green; uint8 blue; + uint8 alpha; }; typedef uint8 gray_color_value; @@ -1154,7 +1156,7 @@ struct CMAP8Reader : public BaseReader { inline void Read(rgb_color_value &color) { converter.RGB24ColorForIndex(*BaseReader::pixels, color.red, color.green, - color.blue); + color.blue, color.alpha); BaseReader::pixels++; } @@ -1268,7 +1270,8 @@ struct RGB32Writer : public BaseWriter<_PixelType> { pixel.red = color.red; pixel.green = color.green; pixel.blue = color.blue; - pixel.alpha = 255; +// pixel.alpha = 255; +pixel.alpha = color.alpha; BaseWriter<_PixelType>::pixels++; }