Surface

D class that wraps SDL_Surface storing a 2D image in the RAM

dsdl2.Surface stores a 2D image out of pixels with a width and height, where each pixel stored in the RAM according to its defined dsdl2.PixelFormat.

@safe final
class Surface {}

Constructors

this
this(SDL_Surface* sdlSurface, bool isOwner, void* userRef)

Constructs a dsdl2.Surface from a vanilla SDL_Surface* from bindbc-sdl

this
this(uint[2] size, PixelFormat rgbPixelFormat)

Constructs a blank RGB(A) dsdl2.Surface with a set width, height, and dsdl2.PixelFormat that wraps SDL_CreateRGBSurface

this
this(void[] pixels, uint[2] size, size_t pitch, PixelFormat rgbPixelFormat)

Constructs an RGB(A) dsdl2.Surface from an array of pixels

this
this(uint[2] size, ubyte bitDepth, Palette palette)

Constructs a blank indexed palette-using dsdl2.Surface with a set width, height, and index bit depth, which wraps SDL_CreateRGBSurface

this
this(void[] pixels, uint[2] size, size_t pitch, ubyte bitDepth, Palette palette)

Constructs a blank indexed palette-using dsdl2.Surface from an array of pixels

Destructor

~this
~this()
Undocumented in source.

Members

Functions

alphaMod
ubyte alphaMod()

Wraps SDL_GetSurfaceAlphaMod which gets the alpha multiplier of the dsdl2.Surface

alphaMod
void alphaMod(ubyte newAlphaMod)

Wraps SDL_SetSurfaceAlphaMod which sets the alpha multiplier of the dsdl2.Surface

blendMode
BlendMode blendMode()

Wraps SDL_GetSurfaceBlendMode which gets the dsdl2.Surface's dsdl2.BlendMode defining blitting

blendMode
void blendMode(BlendMode newMode)

Wraps SDL_SetSurfaceBlendMode which sets the dsdl2.Surface's dsdl2.BlendMode defining blitting

blit
void blit(Surface source, Point destPoint, Rect srcRect)

Wraps SDL_BlitSurface which blits/draws a dsdl2.Surface on top of the dsdl2.Surface at a specific point as the top-left point of the drawn dsdl2.Surface without any scaling done

blit
void blit(Surface source, Point destPoint)

Wraps SDL_BlitSurface which blits/draws a dsdl2.Surface on top of the dsdl2.Surface at a specific point as the top-left point of the drawn dsdl2.Surface without any scaling done

blitScaled
void blitScaled(Surface source, Rect destRect)

Wraps SDL_BlitScaled which blits/draws a dsdl2.Surface on top of the dsdl2.Surface at a specific point as the top-left point of the drawn dsdl2.Surface with scaling

blitScaled
void blitScaled(Surface source, Rect destRect, Rect srcRect)

Wraps SDL_BlitScaled which blits/draws a dsdl2.Surface on top of the dsdl2.Surface at a specific point as the top-left point of the drawn dsdl2.Surface with scaling

buffer
inout(void[]) buffer()

Gets the internal pixel buffer of the dsdl2.Surface

clipRect
Rect clipRect()

Wraps SDL_GetClipRect which gets the clipping dsdl2.Rect of the dsdl2.Surface

clipRect
void clipRect(Rect newRect)

Wraps SDL_SetClipRect which sets the clipping dsdl2.Rect of the dsdl2.Surface

clipRect
void clipRect(typeof(null) _)

Acts as SDL_SetClipRect(surface, NULL) which removes the clipping dsdl2.Rect of the dsdl2.Surface

clipRect
void clipRect(Nullable!Rect newRect)

Wraps SDL_SetClipRect which sets or removes the clipping dsdl2.Rect of the dsdl2.Surface

colorKey
Color colorKey()

Wraps SDL_GetColorKey which gets the color key used by the dsdl2.Surface for transparency

colorKey
void colorKey(uint newPixelKey)

Wraps SDL_SetColorKey which sets the color key used for the dsdl2.Surface making pixels of the same color transparent

colorKey
void colorKey(Color newColorKey)

Wraps SDL_SetColorKey which sets the color key used for the dsdl2.Surface making pixels of the same color transparent

colorKey
void colorKey(typeof(null) _)

Acts as SDL_SetColorKey(surface, NULL) which disables color-keying

colorKey
void colorKey(Nullable!Color newColorKey)

Wraps SDL_SetColorKey which sets or removes the color key used for the dsdl2.Surface making pixels of the same color transparent

colorMod
ubyte[3] colorMod()

Wraps SDL_GetSurfaceColorMod which gets the color multipliers of the dsdl2.Surface

colorMod
void colorMod(ubyte[3] newColorMod)

Wraps SDL_SetSurfaceColorMod which sets the color multipliers of the dsdl2.Surface

convert
Surface convert(PixelFormat rgbPixelFormat)

Wraps SDL_ConvertPixels which converts the dsdl2.Surface from its RGB(A) dsdl2.PixelFormat to another dsdl2.Surface with a different RGB(A) dsdl2.PixelFormat

fill
void fill(uint pixel)

Acts as SDL_FillRect(surface, NULL) which fills the entire dsdl2.Surface with a pixel value

fill
void fill(Color color)

Acts as SDL_FillRect(surface, NULL) which fills the entire dsdl2.Surface with a dsdl2.Color value

fillRect
void fillRect(Rect rect, uint pixel)

Wraps SDL_FillRect which draws a filled rectangle in the dsdl2.Surface with specifying a pixel color value

fillRect
void fillRect(Rect rect, Color color)

Wraps SDL_FillRect which draws a filled rectangle in the dsdl2.Surface with specifying a dsdl2.Color value

fillRects
void fillRects(Rect[] rects, uint pixel)

Wraps SDL_FillRects which draws multiple filled rectangles in the dsdl2.Surface with specifying a pixel color value

fillRects
void fillRects(Rect[] rects, Color color)

Wraps SDL_FillRects which draws multiple filled rectangles in the dsdl2.Surface with specifying a dsdl2.Color value

getAt
Color getAt(uint[2] xy)

Gets the pixel color in the dsdl2.Surface at the given coordinate

getPixelAt
uint getPixelAt(uint[2] xy)

Gets the pixel value in the dsdl2.Surface at the given coordinate

hasColorKey
bool hasColorKey()

Wraps SDL_HasColorKey (from SDL 2.0.9) which checks whether the dsdl2.Surface has a color key for transparency

height
uint height()

Gets the height of the dsdl2.Surface in pixels

mod
Color mod()

Gets the color and alpha multipliers of the dsdl2.Surface that wraps SDL_GetSurfaceColorMod and SDL_GetSurfaceAlphaMod

mod
void mod(Color newMod)

Sets the color and alpha multipliers of the dsdl2.Surface that wraps SDL_SetSurfaceColorMod and SDL_SetSurfaceAlphaMod

opEquals
bool opEquals(Surface rhs)

Equality operator overload

palette
inout(Palette) palette()

Gets the used color palette of the dsdl2.Surface

palette
void palette(Palette newPalette)

Sets the color palette of the dsdl2.Surface

pitch
size_t pitch()

Gets the pitch of the dsdl2.Surface in bytes (multiple of bytes for each line/row)

pixelFormat
const(PixelFormat) pixelFormat()

Gets the dsdl2.PixelFormat of the dsdl2.Surface

setAt
void setAt(uint[2] xy, Color color)

Sets the pixel color in the dsdl2.Surface at the given coordinate

setPixelAt
void setPixelAt(uint[2] xy, uint value)

Sets the pixel value in the dsdl2.Surface at the given coordinate

size
uint[2] size()

Gets the size of the dsdl2.Surface in pixels

toHash
hash_t toHash()

Gets the hash of the dsdl2.Surface

toString
string toString()

Formats the dsdl2.Surface into its construction representation: "dsdl2.PixelFormat([<bytes>], [<width>, <height>], <pitch>, <pixelFormat>)"

width
uint width()

Gets the width of the dsdl2.Surface in pixels

Variables

sdlSurface
SDL_Surface* sdlSurface;

Internal SDL_Surface pointer

Examples

auto surface = new dsdl2.Surface([100, 100], dsdl2.PixelFormat.rgba8888);
surface.fill(dsdl2.Color(24, 24, 24));
surface.fillRect(dsdl2.Rect(25, 25, 50, 50), dsdl2.Color(42, 42, 42));

assert(surface.getAt([0, 0]) == dsdl2.Color(24, 24, 24));
assert(surface.getAt([50, 50]) == dsdl2.Color(42, 42, 42));

Meta