Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

IMG_PixmapRGBA32.h

00001 
00005 
00006 #ifndef _H_IMG_PixmapRGBA32
00007 #define _H_IMG_PixmapRGBA32
00008 
00009 #include "IMG_Pixmap.h"
00010 #include "IMG_MemPtr.h"
00011 #include "IMG_Color.h"
00012 
00013 
00022 
00023 class IMG_PixmapRGBA32 : public IMG_Pixmap {
00024 public:
00026         typedef TUns32 TPixelRGBA32;
00027 
00029         typedef TPixelRGBA32* TPixelPtr;
00030 
00032         IMG_MemPtr<TPixelRGBA32> m_mem;
00033 
00042         IMG_PixmapRGBA32(TUns32 width, TUns32 height);
00043 
00054         IMG_PixmapRGBA32(void* image, TUns32 width, TUns32 height, TUns32 rowBytes);
00055 
00056 #if 0
00057 
00060         virtual ~IMG_PixmapRGBA32();
00061 #endif
00062 
00070         virtual void fillRect(const IMG_Rect& r, const IMG_ColorRGB& c);
00071 
00079         virtual void fillRect(const IMG_Rect& r, const IMG_ColorRGBA& c);
00080 
00090         virtual void setPixmap(const IMG_PixmapRGBA32& src, const IMG_Rect& srcBnds, const IMG_Rect& destBnds);
00091 
00101         virtual void blendPixmap(const IMG_PixmapRGBA32& src, const IMG_Rect& srcBnds, const IMG_Rect& destBnds);
00102 
00103 protected:
00112         inline TPixelPtr getPixelPtr(TUns32 x, TUns32 y) const;
00113 
00119         inline TPixelRGBA32     getPixelValue(const IMG_ColorRGBA& c) const;
00120 
00126         inline void     getColor(TPixelRGBA32 p, IMG_ColorRGBA& c) const;
00127 };
00128 
00129 
00130 inline IMG_PixmapRGBA32::TPixelPtr IMG_PixmapRGBA32::getPixelPtr(TUns32 x, TUns32 y) const
00131 {
00132         return (TPixelPtr) (((TUns8*)m_image) + (y*m_rowBytes) + (x<<2));
00133 }
00134 
00135 
00136 inline IMG_PixmapRGBA32::TPixelRGBA32 IMG_PixmapRGBA32::getPixelValue(const IMG_ColorRGBA& c) const
00137 {
00138         TPixelRGBA32 p = ((TPixelRGBA32) (((float) 0xFF) * c.m_a)) << 24;
00139         p |= ((TPixelRGBA32) (((float) 0xFF) * c.m_b)) << 16;
00140         p |= ((TPixelRGBA32) (((float) 0xFF) * c.m_g)) << 8;
00141         p |= ((TPixelRGBA32) (((float) 0xFF) * c.m_r));
00142         return p;
00143 }
00144 
00145 inline void     IMG_PixmapRGBA32::getColor(TPixelRGBA32 p, IMG_ColorRGBA& c) const
00146 {
00147         c.m_a = ((float) ((p >> 24) & 0x00FF)) / ((float) 0xFF);
00148         c.m_b = ((float) ((p >> 16) & 0x00FF)) / ((float) 0xFF);
00149         c.m_g = ((float) ((p >>  8) & 0x00FF)) / ((float) 0xFF);
00150         c.m_r = ((float) ( p        & 0x00FF)) / ((float) 0xFF);
00151 }
00152 
00153 #endif // _H_IMG_PixmapRGBA32

Generated at Thu May 3 17:29:38 2001 for ImgLib by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000