Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

SurfaceTool Class Reference


Detailed Description

Surface rutines.

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.


Member Function Documentation

void SurfaceTool::alphaFill SDL_Surface *  surface,
SDL_Rect *  dstrect,
const SDL_Color &  color
[static]
 

Fill surface with given color.

Alpha value in color is supported. The final blit rectangle is saved in dstrect.

Parameters:
surface surface to fill
dstrect dstrect or NULL (the whole surface will be filled with color).
color {red, green, blue, alpha}

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 }

SDL_Surface * SurfaceTool::createClone SDL_Surface *  surface  )  [static]
 

Return new cloned surface.

Returns:
new surface, free it after use
Exceptions:
SDLException when function fails

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 }

SDL_Surface * SurfaceTool::createEmpty SDL_Surface *  surface,
int  width = 0,
int  height = 0
[static]
 

Return new empty surface with the same format.

Parameters:
surface surface to ask for pixel format
width width or 0 for the same width
height height or 0 for the same height
Exceptions:
SDLException when function fails

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 }


The documentation for this class was generated from the following files:
Generated on Wed Jun 1 09:57:02 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2