Image

Class for loading, manipulating and saving images.

Image is an abstraction to manipulate images as bidimensional arrays of pixels.

The class provides functions to load, read, write and save pixels, as well as many other useful functions.

Image can handle a unique internal representation of pixels, which is RGBA 32 bits. This means that a pixel must be composed of 8 bits red, green, blue and alpha channels – just like a Color. All the functions that return an array of pixels follow this rule, and all parameters that you pass to Image functions (such as loadFromPixels) must use this representation as well.

A Image can be copied, but it is a heavy resource and if possible you should always use const references to pass or return them to avoid useless copies.

Constructors

this
this()
Undocumented in source.
this
this(sfImage* image)
Undocumented in source.

Destructor

~this
~this()
Undocumented in source.

Members

Functions

copyImage
void copyImage(Image source, uint destX, uint destY, IntRect sourceRect, bool applyAlpha)

Copy pixels from another image onto this one.

create
void create(uint width, uint height, Color color)

Create the image and fill it with a unique color.

create
void create(uint width, uint height, ubyte[] pixels)

Create the image from an array of pixels.

createMaskFromColor
void createMaskFromColor(Color maskColor, ubyte alpha)

Create a transparency mask from a specified color-key.

flipHorizontally
void flipHorizontally()

Flip the image horizontally (left <-> right)

flipVertically
void flipVertically()

Flip the image vertically (top <-> bottom)

getPixel
Color getPixel(uint x, uint y)

Get the color of a pixel

getPixelArray
const(ubyte)[] getPixelArray()

Get the read-only array of pixels that make up the image.

getSize
Vector2u getSize()

Return the size (width and height) of the image.

loadFromFile
bool loadFromFile(string fileName)

Load the image from a file on disk.

loadFromMemory
bool loadFromMemory(const(void)[] data)

Load the image from a file in memory.

loadFromStream
bool loadFromStream(InputStream stream)

Load the image from a custom stream.

saveToFile
bool saveToFile(string fileName)

Save the image to a file on disk.

setPixel
void setPixel(uint x, uint y, Color color)

Change the color of a pixel.

Properties

dup
Image dup [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

sfPtr
sfImage* sfPtr;
Undocumented in source.

See Also

Meta

Authors

Laurent Gomila, Jeremy DeHaan