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

sdlmm_surface.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_SURFACE_H
00023 #define SDLMM_SURFACE_H
00024 
00025 #include "sdlmm_basesurface.h"
00026 
00027 namespace SDLmm {
00029 
00041   class DECLSPEC Surface : public BaseSurface
00042   {
00043   public:
00045 
00051     explicit Surface(SDL_Surface *surface)
00052       : BaseSurface(surface) {
00053     }
00054 
00055     Surface(const Surface& other)
00056       : BaseSurface(other) {
00057       if (me)
00058         ++(me->refcount);
00059     }
00060     
00062 
00068     Surface(): BaseSurface(0) {   }
00069     
00071     Surface &operator=(const Surface& other) {
00072       BaseSurface::operator=(other);
00073       if (me)
00074         ++(me->refcount);
00075       return *this;
00076     }
00077 
00078     Surface Duplicate() const {
00079       Surface new_surface(CreateSurface(*this));
00080       new_surface.Blit(*this); // copy pixels
00081       return new_surface;
00082     }
00083 
00084     static Surface CreateSurface(const BaseSurface& other) {
00085       return Surface(
00086           SDL_CreateRGBSurface(other.w(), other.h(),
00087                                other.GetPixelFormat().BitsPerPixel(),
00088                                other.pitch(),
00089                                other.GetPixelFormat().Rmask(),
00090                                other.GetPixelFormat().Gmask(),
00091                                other.GetPixelFormat().Bmask(),
00092                                other.GetPixelFormat().Amask()));
00093     }
00094 
00096 
00110     static Surface CreateSurface(Uint32 flags, int w, int h, int d,
00111         Uint32 Rmask = 0, Uint32 Gmask = 0,
00112         Uint32 Bmask = 0, Uint32 Amask = 0) {
00113       return Surface(
00114           SDL_CreateRGBSurface(flags, w, h, d,
00115             Rmask, Gmask, Bmask, Amask));
00116     }
00117 
00119 
00134     static Surface CreateSurface(void *pixels, int w, int h, int d, int p,
00135         Uint32 Rmask = 0, Uint32 Gmask = 0,
00136         Uint32 Bmask = 0, Uint32 Amask = 0) {
00137       return Surface(
00138           SDL_CreateRGBSurfaceFrom(pixels, w, h, d, p,
00139             Rmask, Gmask, Bmask, Amask));
00140     }
00141     
00142     // Documented in BaseSurface
00143     virtual bool SetDisplayFormat();
00144     virtual bool SetDisplayFormatAlpha();    
00145         
00147 
00161     static Surface LoadBMP(const char *file) {
00162         return Surface(SDL_LoadBMP(file));
00163     }
00164     
00166 
00170     static Surface LoadBMP(const std::string& file) { return LoadBMP(file.c_str()); }
00171   };
00172 }
00173 
00174 #endif // SDLMM_SURFACE_H
00175 

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