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

sdlmm_pixelformat.h

Go to the documentation of this file.
00001 /*
00002  * SDmm - a C++ wrapper for SDL and related libraries
00003  * Copyright © 2001 David Hedbor <david@hedbor.org>
00004  * 
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License as
00007  * published by the Free Software Foundation; either version 2 of the
00008  * License, or (at your option) any later version.
00009  * 
00010  * This program is distributed in the hope that it will be useful, but
00011  * WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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 DECLSPEC 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 

Documentation automatically generated by doxygen written by Dimitri van Heesch. Project hosted at
Hosted by SourceForge