gfm



class  SDL2Surface;

SDL Surface wrapper.

A  SDL2Surface might own the SDL_Surface* handle or not.


enum  Owned: int;

Whether a SDL Surface is owned by the wrapper or borrowed.


this(SDL2 sdl2, SDL_Surface* surface, Owned owned);

Create from an existing SDL_Surface* handle.


this(SDL2 sdl2, int width, int height, int depth, uint Rmask, uint Gmask, uint Bmask, uint Amask);

Create a new RGBA surface. Both pixels data and handle are owned.

See Also
http://wiki.libsdl.org/SDL_CreateRGBSurface
Throws
SDL2Exception on error.

this(SDL2 sdl2, void* pixels, int width, int height, int depth, int pitch, uint Rmask, uint Gmask, uint Bmask, uint Amask);

Create surface from RGBA data. Pixels data is not and not owned.

See Also
clone, SDL_CreateRGBSurfaceFrom
Throws
SDL2Exception on error.

SDL2Surface  convert(const(SDL_PixelFormat)* newFormat);

Converts the surface to another format.

See Also
http://wiki.libsdl.org/SDL_ConvertSurface
Returns
A new surface.

SDL2Surface  clone();

Returns
A copy of the surface, useful for taking ownership of not-owned pixel data.
See Also
$WEB(wiki.libsdl.org/SDL_CreateRGBSurfaceFrom,SDL_CreateRGBSurfaceFrom)

const @property int  width();

Returns
Width of the surface in pixels.

const @property int  height();

Returns
Height of the surface in pixels.

ubyte*  pixels();

Returns
Pointer to surface data.

You must lock the surface before accessng it.

size_t  pitch();

Get the surface  pitch (number of bytes between lines).


void  lock();

Lock the surface, allow to use pixels().

Throws
SDL2Exception on error.

void  unlock();

Unlock the surface.


SDL_Surface*  handle();

Returns
SDL  handle.

SDL_PixelFormat*  pixelFormat();

Returns
SDL_PixelFormat which describe the surface.

struct  RGBA;




RGBA  getRGBA(int x, int y);

Get a surface pixel color.

Known Bugs
must be locked when using this method. Slow!

void  blit(SDL2Surface source, SDL_Rect srcRect, SDL_Rect dstRect);

Perform a fast surface copy of given source surface to this destination surface.

See Also
http://wiki.libsdl.org/SDL_BlitSurface
Throws
SDL2Exception on error.

void  blitScaled(SDL2Surface source, SDL_Rect srcRect, SDL_Rect dstRect);

Perform a scaled surface copy of given source surface to this destination surface.

See Also
http://wiki.libsdl.org/SDL_BlitScaled
Throws
SDL2Exception on error.