Definition at line 9 of file SurfaceTool.h.
Static Public Member Functions | |
static SDL_Surface * | createEmpty (SDL_Surface *surface, int width=0, int height=0) |
Return new empty surface with the same format. | |
static SDL_Surface * | createClone (SDL_Surface *surface) |
Return new cloned surface. | |
static void | alphaFill (SDL_Surface *surface, SDL_Rect *dstrect, const SDL_Color &color) |
Fill surface with given color. |
|
Fill surface with given color. Alpha value in color is supported. The final blit rectangle is saved in dstrect.
Definition at line 68 of file SurfaceTool.cpp. 00070 { 00071 int w = surface->w; 00072 int h = surface->h; 00073 if (dstrect) { 00074 w = dstrect->w; 00075 h = dstrect->h; 00076 } 00077 SDL_Surface *canvas = createEmpty(surface, w, h); 00078 Uint32 pixel = SDL_MapRGB(canvas->format, color.r, color.g, color.b); 00079 SDL_FillRect(canvas, NULL, pixel); 00080 SDL_SetAlpha(canvas, SDL_SRCALPHA|SDL_RLEACCEL, color.unused); 00081 00082 SDL_BlitSurface(canvas, NULL, surface, dstrect); 00083 SDL_FreeSurface(canvas); 00084 }
|
|
Return new cloned surface.
Definition at line 49 of file SurfaceTool.cpp. 00050 { 00051 SDL_Surface *clone = SDL_ConvertSurface(surface, 00052 surface->format, surface->flags); 00053 if (NULL == clone) { 00054 throw SDLException(ExInfo("ConvertSurface")); 00055 } 00056 return clone; 00057 }
|
|
Return new empty surface with the same format.
Definition at line 22 of file SurfaceTool.cpp. 00023 { 00024 if (!width) { 00025 width = surface->w; 00026 } 00027 if (!height) { 00028 height = surface->h; 00029 } 00030 00031 SDL_Surface *result = SDL_CreateRGBSurface(surface->flags, width, height, 00032 surface->format->BitsPerPixel, 00033 surface->format->Rmask, 00034 surface->format->Gmask, 00035 surface->format->Bmask, 00036 surface->format->Amask); 00037 if (NULL == result) { 00038 throw SDLException(ExInfo("ConvertSurface")); 00039 } 00040 return result; 00041 }
|