00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 #ifndef SDLMM_PIXELFORMAT_H
00023 #define SDLMM_PIXELFORMAT_H
00024 
00025 #include "sdlmm_color.h"
00026 
00027 namespace SDLmm {
00029 
00034   class PixelFormat {
00035   protected:
00037     SDL_PixelFormat *me;
00038 
00039   public:
00041 
00046     explicit PixelFormat(SDL_PixelFormat *pixelformat): me(pixelformat) {  }
00047     
00049     virtual ~PixelFormat() {
00050     };
00051     
00053 
00054 
00055 
00056     bool valid() const { return me != 0; }
00057 
00059     Uint8 BitsPerPixel() const { return me->BitsPerPixel; }
00060     Uint8 BytesPerPixel() const { return me->BytesPerPixel; }
00061     Uint8 Rshift() const { return me->Rshift; }
00062     Uint8 Gshift() const { return me->Gshift; }
00063     Uint8 Bshift() const { return me->Bshift; }
00064 
00065     Uint8 Rloss() const { return me->Rloss; }
00066     Uint8 Gloss() const { return me->Gloss; }
00067     Uint8 Bloss() const { return me->Bloss; }
00068     Uint8 Aloss() const { return me->Aloss; }
00069 
00070     Uint32 Rmask() const { return me->Rmask; }
00071     Uint32 Gmask() const { return me->Gmask; }
00072     Uint32 Bmask() const { return me->Bmask; }
00073     Uint32 Amask() const { return me->Amask; }
00074 
00075     Color colorkey() const { return me->colorkey; }
00076     Uint8 alpha() const { return me->alpha; }
00077     SDL_Palette *palette() const { return me->palette; }
00078 
00080 
00100     Color MapRGB(Uint8 r, Uint8 g, Uint8 b) const;
00101     
00102     Color MapRGB(const ColorRGB& colorrgb) const { return MapRGB(colorrgb.r, colorrgb.g, colorrgb.b); }
00103     
00105 
00125     Color MapRGBA(Uint8 r, Uint8 g, Uint8 b, Uint8 a) const;
00126 
00127     Color MapRGBA(const ColorRGBA& colorrgba) const { return MapRGBA(colorrgba.r, colorrgba.g, colorrgba.b, colorrgba.a); }
00128     
00130 
00142     void GetRGB(Color pixel, Uint8 &r, Uint8 &g, Uint8 &b) const;
00143     
00144     const ColorRGB GetRGB(Color pixel) const
00145     {
00146         ColorRGB        colorrgb;
00147         GetRGB(pixel, colorrgb.r, colorrgb.g, colorrgb.b);
00148         return colorrgb;
00149     }
00150       
00152 
00165     void GetRGBA(Color pixel, Uint8 &r, Uint8 &g, Uint8 &b, Uint8 &a) const;
00166     
00167     const ColorRGBA GetRGBA(Color pixel) const
00168     {
00169         ColorRGBA        colorrgba;
00170         GetRGBA(pixel, colorrgba.r, colorrgba.g, colorrgba.b, colorrgba.a);
00171         return colorrgba;
00172     }
00173   };
00174 }
00175 
00176 #endif // SDLMM_PIXELFORMAT_H
00177