SdlSurface Class Reference
[SDL based classes]

Base class for a graphical surface resource to draw on. More...

#include <sdlsurface.h>

Inheritance diagram for SdlSurface:

Inheritance graph
[legend]
List of all members.

Public Member Functions

DECLSPEC SdlSurface (const char *name)
DECLSPEC SdlSurface (SDL_Surface *surf, const char *name)
DECLSPEC SdlSurface (Uint32 w, Uint32 h, const char *name=(char *)-1, Uint32 flags=SDL_HWSURFACE)
void DECLSPEC rename (const char *newname)
const char * getName () const
 
Returns:
the resource's name

DECLSPEC bool fastBlit (SdlSurface *src_surf, Sint16 xDst, Sint16 yDst, SDL_Rect *src)
DECLSPEC bool fill (SDL_Rect *r, Uint32 color)
DECLSPEC bool zoomBlit (SdlSurface *src_surf, Sint16 xDst, Sint16 yDst, double xZoom, double yZoom, bool smooth=false)
DECLSPEC bool stretchBlit (SdlSurface *src_surf, SDL_Rect *dst, bool smooth=false)
DECLSPEC bool rotozoomBlit (SdlSurface *src_surf, Sint16 xDst, Sint16 yDst, double angle, double zoom, bool smooth=false)
SDL_Surface * surf ()
 
Returns:
a pointer to the surface buffer

void getSize (int &w, int &h)
void getSize (Uint16 &w, Uint16 &h)
Uint32 getWidth () const
 
Returns:
the surface's width

Uint32 getHeight () const
 
Returns:
the surface's height

void setClip (const SDL_Rect &r)
void setNoClip ()
const SDL_Rect & getClip () const
DECLSPEC void setColorKey (Uint32 color)
DECLSPEC void setAlphaValue (int a)
bool lock ()
void unlock ()
virtual DECLSPEC bool saveToFile (const char *fn)

Protected Member Functions

virtual DECLSPEC void onRefresh ()
DECLSPEC void failed ()
 sets the fail-state of the resource

Protected Attributes

SDL_Surface * surface
 pointer to the surface buffer

Detailed Description

Base class for a graphical surface resource to draw on.

This class contains methods for painting/drawing on a surface resource and to get and set information concerning the surface.


Constructor & Destructor Documentation

SdlSurface::SdlSurface ( const char *  name  ) 

Constructor. Registers itself in SdlManager with the given name. After the construction, it cannot be used for drawing, because there is no surface buffer created or assigned.

Parameters:
name the resource's name

SdlSurface::SdlSurface ( SDL_Surface *  surf,
const char *  name 
)

Constructor. Registers itself in SdlManager with the given name. After the construction, the given surface buffer is used.

Parameters:
surf the surface buffer to use; if NULL, this constructor does the same as SdlSurface( const char *name )
name the resource's name
See also:
SdlManager::getSurfaceByName()

SdlSurface::SdlSurface ( Uint32  w,
Uint32  h,
const char *  name = (char *)-1,
Uint32  flags = SDL_HWSURFACE 
)

Constructor. Registers itself in SdlManager with the given name. After the construction, a surface buffer with the given size and flags is availible for usage.

Parameters:
w the width in pixels of the surface buffer to create
h the height in pixels of the surface buffer to create
name the resource's name
flags the flags of the surface, for details, have a look at the SDL documentation; usually SDL_HWSURFACE is the best value.
See also:
SdlManager::getSurfaceByName()


Member Function Documentation

void SdlSurface::rename ( const char *  newname  ) 

Changes the resource's name.

Parameters:
newname the new name of the surface
See also:
SdlManager::getSurfaceByName()

bool SdlSurface::fastBlit ( SdlSurface src_surf,
Sint16  xDst,
Sint16  yDst,
SDL_Rect *  src 
)

Draws the content of another surface onto this surface, using the color key and alpha value of the source surface. This method is (much) faster, than the other blit-functions. When using a transparent alpha value, it will take longer.

Parameters:
src_surf the source surface, its content will be used to draw
xDst the coordinate of the left border, where it will be drawn
yDst the coordinate of the top border, where it will be drawn
src the rect in src_surf, to draw; if NULL, the whole content of src_surf will be drawn
Returns:
true, if successful; false on error

bool SdlSurface::fill ( SDL_Rect *  r,
Uint32  color 
)

Fills a rect with the specified color. This method is usually similar fast as fastBlit() without transparency.

Parameters:
r pointer to the rect to fill; if NULL, the whole surface will be filled.
color the color to use for filling
Returns:
true, if successful; false on error

bool SdlSurface::zoomBlit ( SdlSurface src_surf,
Sint16  xDst,
Sint16  yDst,
double  xZoom,
double  yZoom,
bool  smooth = false 
)

Draws another surface zoomed onto this surface.

Parameters:
src_surf the source surface, its content will be used to draw
xDst the coordinate of the left border, where it will be drawn
yDst the coordinate of the top border, where it will be drawn
xZoom stretch factor to use in x direction i.e. 2 = double size
yZoom stretch factor to use in y direction i.e. 2 = double size
smooth if true, anti aliasing will be used (takes much time)
Returns:
true, if successful; false on error

bool SdlSurface::stretchBlit ( SdlSurface src_surf,
SDL_Rect *  dst,
bool  smooth = false 
)

Draws another surface stretched into a rect of this surface.

Parameters:
src_surf the source surface, its content will be used to draw
dst the rect to draw it in
smooth if true, anti aliasing will be used (takes much time)
Returns:
true, if successful; false on error

bool SdlSurface::rotozoomBlit ( SdlSurface src_surf,
Sint16  xDst,
Sint16  yDst,
double  angle,
double  zoom,
bool  smooth = false 
)

Draws another surface zoomed and rotated onto this surface.

Parameters:
src_surf the source surface, its content will be used to draw
xDst the x-coordinate of the center, where it will be drawn
yDst the y-coordinate of the center, where it will be drawn
angle the angle in degrees (clockwise rotation)
zoom stretch factor to use in both directions (x and y)
smooth if true, anti aliasing will be used (takes much time)
Returns:
true, if successful; false on error

void SdlSurface::getSize ( int &  w,
int &  h 
) [inline]

Parameters:
w the surface's width will be stored here
h the surface's height will be stored here

void SdlSurface::getSize ( Uint16 &  w,
Uint16 &  h 
) [inline]

Parameters:
w the surface's width will be stored here
h the surface's height will be stored here

void SdlSurface::setClip ( const SDL_Rect &  r  )  [inline]

Changes the clip rect. When blitting/filling, nothing will be drawn beyond its borders.

Parameters:
r the new clipping rect

void SdlSurface::setNoClip (  )  [inline]

Changes the clip rect to the whole area of the surface.

const SDL_Rect& SdlSurface::getClip (  )  const [inline]

Returns:
the clipping rect

void SdlSurface::setColorKey ( Uint32  color  ) 

Sets the color, that will be fully transparent when drawing.

Parameters:
color the color to set transparent

void SdlSurface::setAlphaValue ( int  a  ) 

Changes the transparency for blits.

Parameters:
a the new intensity of transparency; range: 0 to 254; if 255 or bigger no transparency will be used (will be drawn with full intensity

bool SdlSurface::lock (  )  [inline]

Locks the surface. When locked, the surface cannot be used for blitting/filling.

Returns:
true, if locking was possible; false on error

void SdlSurface::unlock (  )  [inline]

Unlocks the surface.

bool SdlSurface::saveToFile ( const char *  fn  )  [virtual]

Saves the surface to a bitmap file (BMP format).

virtual DECLSPEC void SdlSurface::onRefresh (  )  [inline, protected, virtual]

Should refresh the surface in a derived class. In this base class, nothing is done.

Reimplemented in SdlFileSurface.


The documentation for this class was generated from the following files:
Generated on Wed May 9 17:36:34 2007 for netrinjo by  doxygen 1.5.1