Surface

Surface is a wrapper for a SDL_Surface.

struct Surface {}

Constructors

this
this(string filename)

CTor

Destructor

~this
~this()
Undocumented in source.

Postblit

this(this)
this(this)
Undocumented in source.

Members

Enums

BlendMode
enum BlendMode

Supported BlendModes

Flip
enum Flip

Flip mode

Mask
enum Mask

Supported Color Masks

Functions

adaptTo
void adaptTo(Surface srfc)

Use this function to adapt the format of another Surface to this surface. Works like <code>SDL_DisplayFormat</code>.

adaptTo
void adaptTo(SDL_PixelFormat* fmt)

Use this function to adapt the format of another Surface to this surface. Works like <code>SLD_DisplayFormat</code>.

blit
bool blit(Surface srfc, ShortRect* src, ShortRect* dst)

Use this function to perform a fast blit from the source surface to the this surface. src is the a pointer to a Rect structure which represents the rectangle to be copied, or null to copy the entire surface. dst is a pointer to a Rect structure which represents the rectangle that is copied into. null means, that the whole srfc is copied to (0|0).

blit
bool blit(SDL_Surface* srfc, ShortRect* src, ShortRect* dst)

Same as above, but with a SDL_Surface* instead of a Surface.

blitScaled
bool blitScaled(Surface srfc, ShortRect* src, ShortRect* dst)

Use this function to perform a fast, low quality, stretch blit between two surfaces of the same pixel format. src is the a pointer to a Rect structure which represents the rectangle to be copied, or null to copy the entire surface. dst is a pointer to a Rect structure which represents the rectangle that is copied into. null means, that the whole srfc is copied to (0|0).

blitScaled
bool blitScaled(SDL_Surface* srfc, ShortRect* src, ShortRect* dst)

Same as above, but with a SDL_Surface* instead of a Surface.

fill
void fill(Color col, ShortRect* rect)

Fills a specific area of the surface with the given color. The second parameter is a pointer to the area. If it's null, the whole Surface is filled.

fill
void fill(Color col, ShortRect* rect)

Rvalue version

fillAreas
void fillAreas(Color col, ShortRect[] rects)

Fills multiple areas of the Surface with the given color.

fillAreas
void fillAreas(Color col, ShortRect[] rects)

Rvalue version

flip
Surface flip(Flip flip)

Returns an new flipped Surface The current Surface is not modified.

free
void free()

Destroy the current Surface <b>and all</b>, which are linked to this Surface</b>.

getAlphaMod
ubyte getAlphaMod()

Returns the current Alpha mod.

getBlendMode
BlendMode getBlendMode()

Returns the current Blendmode.

getClipRect
ShortRect getClipRect()

Returns the clip rect of this surface. The clip rect is the area of the surface which is drawn.

getColorAt
Color getColorAt(Vector2s pos)

Returns the color on the given position.

getColorAt
Color getColorAt(ushort x, ushort y)

Returns the color on the given position.

getColorkey
Color getColorkey()

Returns the current colorkey.

getPixelAt
uint getPixelAt(Vector2s pos)

Returns the pixel at the given coordinates.

getPixelAt
uint getPixelAt(ushort x, ushort y)

Returns the pixel at the given coordinates.

isLocked
bool isLocked()

Returns whether this Surface is locked or not.

isMask
bool isMask(Mask mask, Color col)

Returns if the given color match the color of the given mask of the surface.

isMask
bool isMask(Mask mask, Color col)

Rvalue version

isMask
bool isMask(Mask mask, uint col)

Returns if the given converted color match the color of the given mask of the surface.

isValid
bool isValid()

Returns if the Surface is valid. Which means that the Surface has valid data.

loadFromFile
void loadFromFile(string filename)

Load from filename. If any data is already stored, the data will be freed.

loadFromMemory
void loadFromMemory(void* memory, ushort width, ushort height, ubyte depth)

Load from memory.

lock
bool lock()

Use this function to set up a surface for directly accessing the pixels.

lowerBlit
bool lowerBlit(Surface srfc, ShortRect* src, ShortRect* dst)

Use this function to perform low-level surface blitting only.

lowerBlit
bool lowerBlit(SDL_Surface* srfc, ShortRect* src, ShortRect* dst)

Same as above, but with a SDL_Surface* instead of a Surface.

mustLock
bool mustLock()

Use this function to determine whether a surface must be locked for access.

optimizeRLE
bool optimizeRLE(bool enable)

Use this function to set the RLE acceleration hint for a surface. RLE (Run-Length-Encoding) is a way of compressing data. If RLE is enabled, color key and alpha blending blits are much faster, but the surface must be locked before directly accessing the pixels.

putPixelAt
void putPixelAt(Vector2s pos, uint pixel)

Put a new pixel at the given coordinates.

putPixelAt
void putPixelAt(ushort x, ushort y, uint pixel)

Put a new pixel at the given coordinates.

saveToFile
void saveToFile(string filename)

Save the current pixel data to the file.

setAlphaMod
void setAlphaMod(ubyte alpha)

Set the Alpha mod.

setBlendMode
void setBlendMode(BlendMode mode)

Set the Blendmode.

setClipRect
void setClipRect(ShortRect clip)

Set the clip rect.

setClipRect
void setClipRect(ShortRect clip)

Rvalue version

setColorkey
void setColorkey(Color col)

Set the colorkey.

setColorkey
void setColorkey(Color col)

Rvalue version

setColorkey
void setColorkey(ubyte red, ubyte green, ubyte blue)

Set the colorkey.

setColorkey
void setColorkey(ubyte red, ubyte green, ubyte blue, ubyte alpha)

Set the colorkey.

subSurface
Surface subSurface(ShortRect rect)

Returns a subsurface from this surface. rect represents the viewport. The subsurface is a separate Surface object.

subSurface
Surface subSurface(ShortRect rect)

Rvalue version

unlock
void unlock()

Use this function to release a surface after directly accessing the pixels.

useCount
int useCount()

Returns the current use count

Manifest constants

AMask
enum AMask;
Undocumented in source.
AMask
enum AMask;
Undocumented in source.
BMask
enum BMask;

Default Blue Mask.

GMask
enum GMask;

Default Green Mask.

RMask
enum RMask;

Default Red Mask.

Properties

bits
ubyte bits [@property getter]

Count the bits of this surface. Could be 32, 24, 16, 8, 0.

bytes
ubyte bytes [@property getter]

Count the bytes of this surface. Could be 4, 3, 2, 1, 0. (countBits / 8)

filename
string filename [@property getter]

Returns the current filename, if any

height
ushort height [@property getter]

Returns the height.

pitch
int pitch [@property getter]

Returns the Surface pitch or 0.

pixelFormat
const(SDL_PixelFormat*) pixelFormat [@property getter]

Returns the PixelFormat

pixels
inout(void*) pixels [@property getter]

Returns the pixel data of this surface.

ptr
inout(SDL_Surface)* ptr [@property getter]

Returns a pointer to the SDL_Surface

width
ushort width [@property getter]

Returns the width.

Static functions

make
Surface make(ushort width, ushort height, ubyte depth)

Make a new Surface of the given width, height and depth.

make
Surface make(void* memory, ushort width, ushort height, ubyte depth)

Make an new Surface of the given memory, width, height and depth.

Meta

Authors

rschuett