Class Surface

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

class Surface ;

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.

Constructors

NameDescription
this (sdlSurface, isOwner, userRef) Constructs a dsdl2.Surface from a vanilla SDL_Surface* from bindbc-sdl
this (size, rgbPixelFormat) Constructs a blank RGB(A) dsdl2.Surface with a set width, height, and dsdl2.PixelFormat that wraps SDL_CreateRGBSurface
this (pixels, size, pitch, rgbPixelFormat) Constructs an RGB(A) dsdl2.Surface from an array of pixels
this (size, bitDepth, palette) Constructs a blank indexed palette-using dsdl2.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 dsdl2.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 dsdl2.Surface
alphaMod[set] ubyteWraps SDL_SetSurfaceAlphaMod which sets the alpha multiplier of the dsdl2.Surface
blendMode[get] BlendModeWraps SDL_GetSurfaceBlendMode which gets the dsdl2.Surface's dsdl2.BlendMode defining blitting
blendMode[set] BlendModeWraps SDL_SetSurfaceBlendMode which sets the dsdl2.Surface's dsdl2.BlendMode defining blitting
buffer[get] inout(void[])Gets the internal pixel buffer of the dsdl2.Surface
clipRect[get] RectWraps SDL_GetClipRect which gets the clipping dsdl2.Rect of the dsdl2.Surface
clipRect[set] RectWraps SDL_SetClipRect which sets the clipping dsdl2.Rect of the dsdl2.Surface
clipRect[set] typeof(null)Acts as SDL_SetClipRect(surface, NULL) which removes the clipping dsdl2.Rect of the dsdl2.Surface
clipRect[set] std.typecons.Nullable!(dsdl2.rect.Rect)Wraps SDL_SetClipRect which sets or removes the clipping dsdl2.Rect of the dsdl2.Surface
colorKey[get] ColorWraps SDL_GetColorKey which gets the color key used by the dsdl2.Surface for transparency
colorKey[set] uintWraps SDL_SetColorKey which sets the color key used for the dsdl2.Surface making pixels of the same color transparent
colorKey[set] ColorWraps SDL_SetColorKey which sets the color key used for the dsdl2.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!(dsdl2.pixels.Color)Wraps SDL_SetColorKey which sets or removes the color key used for the dsdl2.Surface making pixels of the same color transparent
colorMod[get] ubyte[3]Wraps SDL_GetSurfaceColorMod which gets the color multipliers of the dsdl2.Surface
colorMod[set] ubyte[3]Wraps SDL_SetSurfaceColorMod which sets the color multipliers of the dsdl2.Surface
hasColorKey[get] boolWraps SDL_HasColorKey (from SDL 2.0.9) which checks whether the dsdl2.Surface has a color key for transparency
height[get] uintGets the height of the dsdl2.Surface in pixels
mod[get] ColorGets the color and alpha multipliers of the dsdl2.Surface that wraps SDL_GetSurfaceColorMod and SDL_GetSurfaceAlphaMod
mod[set] ColorSets the color and alpha multipliers of the dsdl2.Surface that wraps SDL_SetSurfaceColorMod and SDL_SetSurfaceAlphaMod
palette[get] inout(Palette)Gets the used color palette of the dsdl2.Surface
palette[set] PaletteSets the color palette of the dsdl2.Surface
pitch[get] ulongGets the pitch of the dsdl2.Surface in bytes (multiple of bytes for each line/row)
pixelFormat[get] const(PixelFormat)Gets the dsdl2.PixelFormat of the dsdl2.Surface
size[get] uint[2]Gets the size of the dsdl2.Surface in pixels
width[get] uintGets the width of the dsdl2.Surface in pixels

Methods

NameDescription
blit (source, destPoint, 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 (source, 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 (source, 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 (source, destRect, 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
convert (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 (pixel) Acts as SDL_FillRect(surface, NULL) which fills the entire dsdl2.Surface with a pixel value
fill (color) Acts as SDL_FillRect(surface, NULL) which fills the entire dsdl2.Surface with a dsdl2.Color value
fillRect (rect, pixel) Wraps SDL_FillRect which draws a filled rectangle in the dsdl2.Surface with specifying a pixel color value
fillRect (rect, color) Wraps SDL_FillRect which draws a filled rectangle in the dsdl2.Surface with specifying a dsdl2.Color value
fillRects (rects, pixel) Wraps SDL_FillRects which draws multiple filled rectangles in the dsdl2.Surface with specifying a pixel color value
fillRects (rects, color) Wraps SDL_FillRects which draws multiple filled rectangles in the dsdl2.Surface with specifying a dsdl2.Color value
getAt (xy) Gets the pixel color in the dsdl2.Surface at the given coordinate
getPixelAt (xy) Gets the pixel value in the dsdl2.Surface at the given coordinate
opEquals (rhs) Equality operator overload
setAt (xy, color) Sets the pixel color in the dsdl2.Surface at the given coordinate
setPixelAt (xy, value) Sets the pixel value in the dsdl2.Surface at the given coordinate
toHash () Gets the hash of the dsdl2.Surface
toString () Formats the dsdl2.Surface into its construction representation: "dsdl2.PixelFormat([<bytes>], [<width>, <height>], <pitch>, <pixelFormat>)"

Example

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));