Dgame.Graphic.Surface

« Go back

Bottom


struct Masks;
The RGBA-Mask are the bitmasks used to extract that color from a pixel. It is used to e.g. define the background of a newly created Surface. Using zeros for the RGB-Masks sets a default value, based on the depth But using zero for the Aalpha-Mask results in an Alpha-Mask of 0. By default Surfaces with an Alpha-Mask are set up for blending. You can change the blend mode with Surface.setBlendMode.

static immutable Masks Default;
The default value. Same as Masks.init. The RGBA-Masks depend on the endianness (byte order) of the machine

static immutable Masks Zero;
The RGBA-Masks are zero

uint red;
the red mask, default is 0x000000ff

uint green;
the green mask, default is 0x0000ff00

uint blue;
the blue mask, default is 0x00ff0000

uint alpha;
the alpha mask, default is 0xff000000

pure nothrow @nogc this(uint red, uint green, uint blue, uint alpha);
CTor

struct Surface;
Surface is a wrapper for a SDL_Surface and can load and save images.

Author:
Randy Schuett (rswhite4@googlemail.com)

enum BlendMode: ubyte;
Supported BlendModes

None
no blending

Blend
dst = (src * A) + (dst * (1-A))

Add
dst = (src * A) + dst

Mod
dst = src * dst

enum Mask: ubyte;
Supported Color Masks

Red
Red Mask

Green
Green Mask

Blue
Blue Mask

Alpha
Alpha Mask

nothrow @nogc this(SDL_Surface* srfc);
CTor

nothrow @nogc this(string filename);
CTor

nothrow @nogc this(uint width, uint height, ubyte depth = 32, const Masks mask = Masks.init);
Make a new Surface of the given width, height and depth.

nothrow @nogc this(void* memory, uint width, uint height, ubyte depth = 32, const Masks mask = Masks.init);
Make an new Surface of the given memory, width, height and depth.

const pure nothrow @nogc @property int refCount();
Returns the current ref count / usage

const pure nothrow @nogc bool isValid();
Returns if the Surface is valid. Which means that the Surface has valid data.

nothrow @nogc bool loadFromFile(string filename);
Load from filename. If any data is already stored, the data will be freed.

nothrow @nogc bool loadFromMemory(void* memory, ushort width, ushort height, ubyte depth = 32, const Masks mask = Masks.init);
Load from memory.

nothrow @nogc bool saveToFile(string filename);
Save the current pixel data to the file.

nothrow @nogc void fill()(auto ref const Color4b col, const Rect* rect = null);
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.

nothrow @nogc 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.

Returns:
whether the call succeeded or not

nothrow @nogc bool lock();
Use this function to set up a surface for directly accessing the pixels.

Returns:
whether the call succeeded or not

nothrow @nogc void unlock();
Use this function to release a surface after directly accessing the pixels.

const pure nothrow @nogc bool isLocked();
Returns whether this Surface is locked or not.

nothrow @nogc bool mustLock();
Use this function to determine whether a surface must be locked for access.

nothrow @nogc void adaptTo(ref Surface srfc);
Use this function to adapt the format of another Surface to this surface. Works like SDL_DisplayFormat.

nothrow @nogc bool adaptTo(const SDL_PixelFormat* fmt);
Use this function to adapt the format of another Surface to this surface. Works like SLD_DisplayFormat.

nothrow @nogc void setColorkey()(auto ref const Color4b col);
Set the colorkey.

nothrow @nogc Color4b getColorkey();
Returns the current colorkey.

nothrow @nogc void setAlphaMod(ubyte alpha);
Set the Alpha mod.

nothrow @nogc ubyte getAlphaMod();
Returns the current Alpha mod.

nothrow @nogc void setBlendMode(BlendMode mode);
Set the Blendmode.

nothrow @nogc BlendMode getBlendMode();
Returns the current Blendmode.

nothrow @nogc Rect getClipRect();
Returns the clip rect of this surface. The clip rect is the area of the surface which is drawn.

nothrow @nogc void setClipRect()(auto ref const Rect clip);
Set the clip rect.

const pure nothrow @nogc @property int width();
Returns the width.

const pure nothrow @nogc @property int height();
Returns the height.

inout pure nothrow @nogc @property inout(void*) pixels();
Returns the pixel data of this surface.

const pure nothrow @nogc @property ubyte bits();
Count the bits of this surface. Could be 32, 24, 16, 8, 0.

const pure nothrow @nogc @property ubyte bytes();
Count the bytes of this surface. Could be 4, 3, 2, 1, 0. (countBits / 8)

const pure nothrow @nogc @property int pitch();
Returns the Surface pitch or 0.

const pure nothrow @nogc @property const(SDL_PixelFormat*) format();
Returns the PixelFormat

const nothrow @nogc bool isMask()(Mask mask, auto ref const Color4b col);
Returns if the given color match the color of the given mask of the surface.

See:
Surface.Mask enum.

const pure nothrow @nogc bool isMask(Mask mask, uint col);
Returns if the given converted color match the color of the given mask of the surface.

See:
Surface.Mask enum.

const nothrow @nogc int getPixelAt()(auto ref const Vector2i pos);
Returns the pixel at the given coordinates.

nothrow @nogc void putPixelAt()(auto ref const Vector2i pos, uint pixel);
Put a new pixel at the given coordinates.

const nothrow @nogc Color4b getColorAt()(auto ref const Vector2i pos);
Returns the color on the given position.

nothrow @nogc bool blitScaled(ref Surface srfc, const Rect* src = null, Rect* dst = null);
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).

nothrow @nogc bool blit(ref Surface srfc, const Rect* src = null, Rect* dst = null);
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).

nothrow @nogc Surface subSurface()(auto ref const Rect rect);
Returns a subsurface from this surface. rect represents the viewport. The subsurface is a separate Surface object.


Page generated by Ddoc.

» Dgame.Graphic.Surface on Github

Top

« Go back