Dgame.Graphic.Surface
« Go back
Bottom- 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
- 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 masks = 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 masks = 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 masks = Masks.init);
- Load from memory.
- nothrow @nogc bool saveToFile(string filename);
- Save the current pixel data to the file.
- nothrow @nogc void fill(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 bool adaptTo(ref Surface srfc);
- Use this function to adapt the format of another Surface to this surface.
- nothrow @nogc bool adaptTo(ubyte depth);
- Use this function to adapt the format of another Surface depth to this surface.
- nothrow @nogc void setColorkey(const Color4b col);
- Set the colorkey.
- nothrow @nogc Color4b getColorkey();
- Returns the current colorkey,
or Color4b.Black, if the Surface is invalid
- 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(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 Masks getMasks();
- Returns the Surface color Masks
- const nothrow @nogc int getPixelAt(int x, int y);
- Returns the pixel at the given coordinates.
- const nothrow @nogc int getPixelAt(const Vector2i pos);
- Returns the pixel at the given coordinates.
- nothrow @nogc void putPixelAt(const Vector2i pos, uint pixel);
- Put a new pixel at the given coordinates.
- const nothrow @nogc Color4b getColorAt(int x, int y);
- Returns the color on the given position,
or Color4b.Black if the position is out of range.
- const nothrow @nogc Color4b getColorAt(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(const Rect rect);
- Returns a subsurface from this surface. rect represents the viewport.
The subsurface is a separate Surface object.
Page generated by Ddoc.
« Go back