#include <CSFML/Graphics/Export.h>
#include <CSFML/Graphics/Color.h>
#include <CSFML/Graphics/Rect.h>
#include <CSFML/Graphics/Types.h>
#include <CSFML/System/Buffer.h>
#include <CSFML/System/InputStream.h>
#include <CSFML/System/Vector2.h>
#include <stddef.h>
Go to the source code of this file.
Functions | |
sfImage * | sfImage_create (sfVector2u size) |
Create an image. | |
sfImage * | sfImage_createFromColor (sfVector2u size, sfColor color) |
Create an image and fill it with a unique color. | |
sfImage * | sfImage_createFromPixels (sfVector2u size, const uint8_t *pixels) |
Create an image from an array of pixels. | |
sfImage * | sfImage_createFromFile (const char *filename) |
Create an image from a file on disk. | |
sfImage * | sfImage_createFromMemory (const void *data, size_t size) |
Create an image from a file in memory. | |
sfImage * | sfImage_createFromStream (sfInputStream *stream) |
Create an image from a custom stream. | |
sfImage * | sfImage_copy (const sfImage *image) |
Copy an existing image. | |
void | sfImage_destroy (const sfImage *image) |
Destroy an existing image. | |
bool | sfImage_saveToFile (const sfImage *image, const char *filename) |
Save an image to a file on disk. | |
bool | sfImage_saveToMemory (const sfImage *image, sfBuffer *output, const char *format) |
Save the image to a buffer in memory. | |
sfVector2u | sfImage_getSize (const sfImage *image) |
Return the size of an image. | |
void | sfImage_createMaskFromColor (sfImage *image, sfColor color, uint8_t alpha) |
Create a transparency mask from a specified color-key. | |
bool | sfImage_copyImage (sfImage *image, const sfImage *source, sfVector2u dest, sfIntRect sourceRect, bool applyAlpha) |
Copy pixels from an image onto another. | |
void | sfImage_setPixel (sfImage *image, sfVector2u coords, sfColor color) |
Change the color of a pixel in an image. | |
sfColor | sfImage_getPixel (const sfImage *image, sfVector2u coords) |
Get the color of a pixel in an image. | |
const uint8_t * | sfImage_getPixelsPtr (const sfImage *image) |
Get a read-only pointer to the array of pixels of an image. | |
void | sfImage_flipHorizontally (sfImage *image) |
Flip an image horizontally (left <-> right) | |
void | sfImage_flipVertically (sfImage *image) |
Flip an image vertically (top <-> bottom) | |
Function Documentation
◆ sfImage_copy()
Copy an existing image.
- Parameters
-
image Image to copy
- Returns
- Copied object
◆ sfImage_copyImage()
bool sfImage_copyImage | ( | sfImage * | image, |
const sfImage * | source, | ||
sfVector2u | dest, | ||
sfIntRect | sourceRect, | ||
bool | applyAlpha | ||
) |
Copy pixels from an image onto another.
This function does a slow pixel copy and should not be used intensively. It can be used to prepare a complex static image from several others, but if you need this kind of feature in real-time you'd better use sfRenderTexture.
If sourceRect is empty, the whole image is copied. If applyAlpha is set to true, the transparency of source pixels is applied. If it is false, the pixels are copied unchanged with their alpha value.
- Parameters
-
image Image object source Source image to copy dest Coordinates of the destination position sourceRect Sub-rectangle of the source image to copy applyAlpha Should the copy take in account the source transparency?
- Returns
- True if the operation was successful, false otherwise
◆ sfImage_create()
sfImage * sfImage_create | ( | sfVector2u | size | ) |
Create an image.
This image is filled with black pixels.
- Parameters
-
size Size of the image
- Returns
- A new sfImage object
◆ sfImage_createFromColor()
sfImage * sfImage_createFromColor | ( | sfVector2u | size, |
sfColor | color | ||
) |
Create an image and fill it with a unique color.
- Parameters
-
size Size of the image color Fill color
- Returns
- A new sfImage object
◆ sfImage_createFromFile()
sfImage * sfImage_createFromFile | ( | const char * | filename | ) |
Create an image from a file on disk.
The supported image formats are bmp, png, tga, jpg, gif, psd, hdr and pic. Some format options are not supported, like progressive jpeg. If this function fails, the image is left unchanged.
- Parameters
-
filename Path of the image file to load
- Returns
- A new sfImage object, or NULL if it failed
◆ sfImage_createFromMemory()
sfImage * sfImage_createFromMemory | ( | const void * | data, |
size_t | size | ||
) |
Create an image from a file in memory.
The supported image formats are bmp, png, tga, jpg, gif, psd, hdr and pic. Some format options are not supported, like progressive jpeg. If this function fails, the image is left unchanged.
- Parameters
-
data Pointer to the file data in memory size Size of the data to load, in bytes
- Returns
- A new sfImage object, or NULL if it failed
◆ sfImage_createFromPixels()
sfImage * sfImage_createFromPixels | ( | sfVector2u | size, |
const uint8_t * | pixels | ||
) |
Create an image from an array of pixels.
The pixel array is assumed to contain 32-bits RGBA pixels, and have the given width and height. If not, this is an undefined behaviour. If pixels is null, an empty image is created.
- Parameters
-
size Size of the image pixels Array of pixels to copy to the image
- Returns
- A new sfImage object
◆ sfImage_createFromStream()
sfImage * sfImage_createFromStream | ( | sfInputStream * | stream | ) |
Create an image from a custom stream.
The supported image formats are bmp, png, tga, jpg, gif, psd, hdr and pic. Some format options are not supported, like progressive jpeg. If this function fails, the image is left unchanged.
- Parameters
-
stream Source stream to read from
- Returns
- A new sfImage object, or NULL if it failed
◆ sfImage_createMaskFromColor()
Create a transparency mask from a specified color-key.
This function sets the alpha value of every pixel matching the given color to alpha (0 by default), so that they become transparent.
- Parameters
-
image Image object color Color to make transparent alpha Alpha value to assign to transparent pixels
◆ sfImage_destroy()
void sfImage_destroy | ( | const sfImage * | image | ) |
Destroy an existing image.
- Parameters
-
image Image to delete
◆ sfImage_flipHorizontally()
void sfImage_flipHorizontally | ( | sfImage * | image | ) |
Flip an image horizontally (left <-> right)
- Parameters
-
image Image object
◆ sfImage_flipVertically()
void sfImage_flipVertically | ( | sfImage * | image | ) |
Flip an image vertically (top <-> bottom)
- Parameters
-
image Image object
◆ sfImage_getPixel()
sfColor sfImage_getPixel | ( | const sfImage * | image, |
sfVector2u | coords | ||
) |
Get the color of a pixel in an image.
This function doesn't check the validity of the pixel coordinates, using out-of-range values will result in an undefined behaviour.
- Parameters
-
image Image object coords Coordinates of pixel to get
- Returns
- Color of the pixel at coordinates (x, y)
◆ sfImage_getPixelsPtr()
const uint8_t * sfImage_getPixelsPtr | ( | const sfImage * | image | ) |
Get a read-only pointer to the array of pixels of an image.
The returned value points to an array of RGBA pixels made of 8 bits integers components. The size of the array is getWidth() * getHeight() * 4. Warning: the returned pointer may become invalid if you modify the image, so you should never store it for too long. If the image is empty, a null pointer is returned.
- Parameters
-
image Image object
- Returns
- Read-only pointer to the array of pixels
◆ sfImage_getSize()
sfVector2u sfImage_getSize | ( | const sfImage * | image | ) |
Return the size of an image.
- Parameters
-
image Image object
- Returns
- Size in pixels
◆ sfImage_saveToFile()
bool sfImage_saveToFile | ( | const sfImage * | image, |
const char * | filename | ||
) |
Save an image to a file on disk.
The format of the image is automatically deduced from the extension. The supported image formats are bmp, png, tga and jpg. The destination file is overwritten if it already exists. This function fails if the image is empty.
- Parameters
-
image Image object filename Path of the file to save
- Returns
- true if saving was successful
- See also
- sfImage_saveToMemory
◆ sfImage_saveToMemory()
Save the image to a buffer in memory.
The format of the image must be specified. The supported image formats are bmp, png, tga and jpg. This function fails if the image is empty, or if the format was invalid.
- Parameters
-
image Image object output Buffer to fill with encoded data format Encoding format to use
- Returns
- true if saving was successful
- See also
- sfImage_saveToFile
◆ sfImage_setPixel()
void sfImage_setPixel | ( | sfImage * | image, |
sfVector2u | coords, | ||
sfColor | color | ||
) |
Change the color of a pixel in an image.
This function doesn't check the validity of the pixel coordinates, using out-of-range values will result in an undefined behaviour.
- Parameters
-
image Image object coords Coordinates of pixel to change color New color of the pixel