sdlpixelformat.h

Go to the documentation of this file.
00001 /*
00002   libwt - Vassilis Virvilis Toolkit - a widget library
00003   Copyright (C) 2006 Vassilis Virvilis <vasvir2@fastmail.fm>
00004  
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Lesser General Public
00007   License as published by the Free Software Foundation; either
00008   version 2.1 of the License, or (at your option) any later version.
00009   
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Lesser General Public License for more details.
00014   
00015   You should have received a copy of the GNU Lesser General Public
00016   License along with this library; if not, write to the
00017   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018   Boston, MA  02111-1307, SA.
00019 */
00020 
00021 #ifndef WT_SDLPIXELFORMAT_H
00022 #define WT_SDLPIXELFORMAT_H
00023 
00024 // SDL_PixelFormat
00025 #include <SDL/SDL_video.h>
00026 
00027 #include "sdlpalette.h"
00028 #include "sdlcolor.h"
00029 
00030 namespace Wt {
00031 
00032 /*!
00033 \note SDLPixelFormat encapsulates a pointer and not the direct struct
00034 as opposed to SDLRect, SDLColor.
00035 */
00036 class SDLPixelFormat {
00037 public:
00038     /// copy constructor
00039     SDLPixelFormat(SDL_PixelFormat* pf)
00040             : sdl_pixelformat(pf) {
00041         assert(sizeof(SDLPixelFormat) == sizeof(SDL_PixelFormat*));
00042     }
00043 
00044     /// assign operator
00045     SDLPixelFormat& operator=(SDL_PixelFormat* pf) {
00046         sdl_pixelformat = pf;
00047         return *this;
00048     }
00049 
00050     //cast operators for automatic downcasting of our childs
00051     operator const SDL_PixelFormat* () const {
00052         return sdl_pixelformat;
00053     }
00054 
00055     operator SDL_PixelFormat* ()  {
00056         return sdl_pixelformat;
00057     }
00058 
00059     const SDLPalette palette() const {
00060         return sdl_pixelformat->palette;
00061     }
00062 
00063     int bitsPerPixel() const {
00064         return sdl_pixelformat->BitsPerPixel;
00065     }
00066 
00067     int bytesPerPixel() const {
00068         return sdl_pixelformat->BytesPerPixel;
00069     }
00070 
00071     int redMask() const {
00072         return sdl_pixelformat->Rmask;
00073     }
00074 
00075     int greenMask() const {
00076         return sdl_pixelformat->Gmask;
00077     }
00078 
00079     int blueMask() const {
00080         return sdl_pixelformat->Bmask;
00081     }
00082 
00083     int alphaMask() const {
00084         return sdl_pixelformat->Amask;
00085     }
00086 
00087     int redShift() const {
00088         return sdl_pixelformat->Rshift;
00089     }
00090 
00091     int greenShift() const {
00092         return sdl_pixelformat->Gshift;
00093     }
00094 
00095     int blueShift() const {
00096         return sdl_pixelformat->Bshift;
00097     }
00098 
00099     int alphaShift() const {
00100         return sdl_pixelformat->Ashift;
00101     }
00102 
00103     int redLoss() const {
00104         return sdl_pixelformat->Rloss;
00105     }
00106 
00107     int greenLoss() const {
00108         return sdl_pixelformat->Gloss;
00109     }
00110 
00111     int blueLoss() const {
00112         return sdl_pixelformat->Bloss;
00113     }
00114 
00115     int alphaLoss() const {
00116         return sdl_pixelformat->Aloss;
00117     }
00118 
00119     int transparentPixelValue() const {
00120         return sdl_pixelformat->colorkey;
00121     }
00122 
00123     int alpha() const {
00124         return sdl_pixelformat->alpha;
00125     }
00126 
00127     SDLColor mapToColor(int v) const;
00128 
00129     int mapToPixelValue(const SDLColor& c) const;
00130 
00131     SDLColor transparentColor() const;
00132 
00133 private:
00134     /// private constructor
00135     SDLPixelFormat() {}
00136 
00137     SDL_PixelFormat* sdl_pixelformat;
00138 };
00139 
00140 }
00141 
00142 #endif // _SDLPIXELFORMAT_H

Generated Fri Jul 28 19:23:00 2006.
Copyright © 1998-2003 by the respective authors.

This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.