Class Surface

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

class Surface ;

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

Constructors

NameDescription
this (sdlSurface, isOwner, userRef) Constructs a dsdl.Surface from a vanilla SDL_Surface* from bindbc-sdl
this (size, rgbPixelFormat) Constructs a blank RGB(A) dsdl.Surface with a set width, height, and dsdl.PixelFormat that wraps SDL_CreateRGBSurface
this (pixels, size, pitch, rgbPixelFormat) Constructs an RGB(A) dsdl.Surface from an array of pixels
this (size, bitDepth, palette) Constructs a blank indexed palette-using dsdl.Surface with a set width, height, and index bit depth, which wraps SDL_CreateRGBSurface
this (pixels, size, pitch, bitDepth, palette) Constructs a blank indexed palette-using dsdl.Surface from an array of pixels

Fields

NameTypeDescription
sdlSurface sdl.surface.SDL_Surface*Internal SDL_Surface pointer

Properties

NameTypeDescription
alphaMod[get] ubyteWraps SDL_GetSurfaceAlphaMod which gets the alpha multiplier of the dsdl.Surface
alphaMod[set] ubyteWraps SDL_SetSurfaceAlphaMod which sets the alpha multiplier of the dsdl.Surface
blendMode[get] BlendModeWraps SDL_GetSurfaceBlendMode which gets the dsdl.Surface's dsdl.BlendMode defining blitting
blendMode[set] BlendModeWraps SDL_SetSurfaceBlendMode which sets the dsdl.Surface's dsdl.BlendMode defining blitting
buffer[get] inout(void[])Gets the internal pixel buffer of the dsdl.Surface
clipRect[get] RectWraps SDL_GetClipRect which gets the clipping dsdl.Rect of the dsdl.Surface
clipRect[set] RectWraps SDL_SetClipRect which sets the clipping dsdl.Rect of the dsdl.Surface
clipRect[set] typeof(null)Acts as SDL_SetClipRect(surface, NULL) which removes the clipping dsdl.Rect of the dsdl.Surface
clipRect[set] std.typecons.Nullable!(dsdl.rect.Rect)Wraps SDL_SetClipRect which sets or removes the clipping dsdl.Rect of the dsdl.Surface
colorKey[get] ColorWraps SDL_GetColorKey which gets the color key used by the dsdl.Surface for transparency
colorKey[set] uintWraps SDL_SetColorKey which sets the color key used for the dsdl.Surface making pixels of the same color transparent
colorKey[set] ColorWraps SDL_SetColorKey which sets the color key used for the dsdl.Surface making pixels of the same color transparent
colorKey[set] typeof(null)Acts as SDL_SetColorKey(surface, NULL) which disables color-keying
colorKey[set] std.typecons.Nullable!(dsdl.pixels.Color)Wraps SDL_SetColorKey which sets or removes the color key used for the dsdl.Surface making pixels of the same color transparent
colorMod[get] ubyte[3]Wraps SDL_GetSurfaceColorMod which gets the color multipliers of the dsdl.Surface
colorMod[set] ubyte[3]Wraps SDL_SetSurfaceColorMod which sets the color multipliers of the dsdl.Surface
hasColorKey[get] boolWraps SDL_HasColorKey (from SDL 2.0.9) which checks whether the dsdl.Surface has a color key for transparency
height[get] uintGets the height of the dsdl.Surface in pixels
mod[get] ColorGets the color and alpha multipliers of the dsdl.Surface that wraps SDL_GetSurfaceColorMod and SDL_GetSurfaceAlphaMod
mod[set] ColorSets the color and alpha multipliers of the dsdl.Surface that wraps SDL_SetSurfaceColorMod and SDL_SetSurfaceAlphaMod
palette[get] inout(Palette)Gets the used color palette of the dsdl.Surface
palette[set] PaletteSets the color palette of the dsdl.Surface
pitch[get] ulongGets the pitch of the dsdl.Surface in bytes (multiple of bytes for each line/row)
pixelFormat[get] const(PixelFormat)Gets the dsdl.PixelFormat of the dsdl.Surface
size[get] uint[2]Gets the size of the dsdl.Surface in pixels
width[get] uintGets the width of the dsdl.Surface in pixels

Methods

NameDescription
blit (source, destPoint, srcRect) Wraps SDL_BlitSurface which blits/draws a dsdl.Surface on top of the dsdl.Surface at a specific point as the top-left point of the drawn dsdl.Surface without any scaling done
blit (source, destPoint) Wraps SDL_BlitSurface which blits/draws a dsdl.Surface on top of the dsdl.Surface at a specific point as the top-left point of the drawn dsdl.Surface without any scaling done
blitScaled (source, destRect) Wraps SDL_BlitScaled which blits/draws a dsdl.Surface on top of the dsdl.Surface at a specific point as the top-left point of the drawn dsdl.Surface with scaling
blitScaled (source, destRect, srcRect) Wraps SDL_BlitScaled which blits/draws a dsdl.Surface on top of the dsdl.Surface at a specific point as the top-left point of the drawn dsdl.Surface with scaling
convert (rgbPixelFormat) Wraps SDL_ConvertPixels which converts the dsdl.Surface from its RGB(A) dsdl.PixelFormat to another dsdl.Surface with a different RGB(A) dsdl.PixelFormat
fill (pixel) Acts as SDL_FillRect(surface, NULL) which fills the entire dsdl.Surface with a pixel value
fill (color) Acts as SDL_FillRect(surface, NULL) which fills the entire dsdl.Surface with a dsdl.Color value
fillRect (rect, pixel) Wraps SDL_FillRect which draws a filled rectangle in the dsdl.Surface with specifying a pixel color value
fillRect (rect, color) Wraps SDL_FillRect which draws a filled rectangle in the dsdl.Surface with specifying a dsdl.Color value
fillRects (rects, pixel) Wraps SDL_FillRects which draws multiple filled rectangles in the dsdl.Surface with specifying a pixel color value
fillRects (rects, color) Wraps SDL_FillRects which draws multiple filled rectangles in the dsdl.Surface with specifying a dsdl.Color value
getAt (xy) Gets the pixel color in the dsdl.Surface at the given coordinate
getPixelAt (xy) Gets the pixel value in the dsdl.Surface at the given coordinate
opEquals (rhs) Equality operator overload
setAt (xy, color) Sets the pixel color in the dsdl.Surface at the given coordinate
setPixelAt (xy, value) Sets the pixel value in the dsdl.Surface at the given coordinate
toHash () Gets the hash of the dsdl.Surface
toString () Formats the dsdl.Surface into its construction representation: "dsdl.PixelFormat([<bytes>], [<width>, <height>], <pitch>, <pixelFormat>)"

Example

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

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