sdlmm_surface.h Source File (original) (raw)

00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 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); 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
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