dsfml.graphics.image



class Image;
Image is the low-level class for loading and manipulating images

this();
Default constructor

this(uint width, uint height, Color col = (Color).BLACK);
Construct an empty image

Params:
uint width Image width
uint height Image height
Color col Image color (black by default)

this(uint width, uint height, ubyte[] data);
Construct the image from pixels in memory

Params:
uint width Image width
uint height Image height
ubyte[] data array of pixels in memory (assumed format is RGBA)

bool loadFromFile(char[] filename);
Load the surface from a file

Params:
char[] filename Path of the image file to load

Returns:
True if loading was successful

bool loadFromMemory(byte[] data);
Load the surface from a file in memory

Params:
byte[] data array of data in memory

Returns:
True if loading was successful

bool loadFromPixels(uint width, uint height, ubyte[] data);
Load the image directly from an array of pixels

Params:
uint width Image width
uint height Image height
ubyte[] data array of pixels in memory (assumed format is RGBA)

Returns:
True if loading was successful

bool saveToFile(char[] filename);
Save the content of the image to a file

Params:
char[] filename Path of the file to save (overwritten if already exist)

Returns:
True if saving was successful

bool create(uint width, uint height, Color col = BLACK);
Create an empty image

Params:
uint width Image width
uint height Image height
Color col Image color (black by default)

Returns:
True if creation was successful

void createMaskFromColor(Color colorKey, ubyte alpha = cast(ubyte)0);
Create transparency mask from a specified colorkey

Params:
Color colorKey Color to become transparent
ubyte alpha Alpha value to use for transparent pixels (0 by default)

bool resize(uint width, uint height, Color col = BLACK);
Resize the image - warning : this function does not scale the image, it just ajdusts size (add padding or remove pixels)

Params:
uint width New width
uint height New height
Color col Color to assign to new pixels (black by default)

Returns:
True if resize has been successful

void setPixel(uint x, uint y, Color col);
Change the color of a pixel Don't forget to call Update when you end modifying pixels

Params:
uint x X coordinate of pixel in the image
uint y Y coordinate of pixel in the image
Color col New color for pixel (X, Y)

Color getPixel(uint x, uint y);
Get a pixel from the image

Params:
uint x X coordinate of pixel in the image
uint y Y coordinate of pixel in the image

Returns:
Color of pixel (x, y)

ubyte[] getPixelsPtr();
Get a pointer to the array of pixels (8 bits integers RGBA) Array size is GetWidth() x GetHeight() x 4 This pointer becomes invalid if you reload or resize the image

Returns:
array of pixels

void bind();
Bind the image for rendering

void setSmooth(bool smooth);
Enable or disable image smooth filter. This parameter is enabled by default

Params:
bool smooth True to enable smoothing filter, false to disable it

uint getWidth();
Return the width of the image

Returns:
Width in pixels

uint getHeight();
Return the height of the image

Returns:
Height in pixels

bool isSmooth();
Tells whether the smooth filtering is enabled or not

Returns:
True if image smoothing is enabled


Page generated by Ddoc.