Image.h File Reference

#include <SFML/Config.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h>

Go to the source code of this file.


Typedefs

typedef sfRenderWindow sfRenderWindow
typedef sfImage sfImage
 sfImage is the low-level class for loading and manipulating images

Functions

CSFML_API sfImagesfImage_Create ()
 Create a new empty image.
CSFML_API sfImagesfImage_CreateFromColor (unsigned int Width, unsigned int Height, sfColor Color)
 Create a new image filled with a color.
CSFML_API sfImagesfImage_CreateFromPixels (unsigned int Width, unsigned int Height, const sfUint8 *Data)
 Create a new image from an array of pixels in memory.
CSFML_API sfImagesfImage_CreateFromFile (const char *Filename)
 Create a new image from a file.
CSFML_API sfImagesfImage_CreateFromMemory (const char *Data, size_t SizeInBytes)
 Create a new image from a file in memory.
CSFML_API void sfImage_Destroy (sfImage *Image)
 Destroy an existing image.
CSFML_API sfBool sfImage_SaveToFile (sfImage *Image, const char *Filename)
 Save the content of an image to a file.
CSFML_API void sfImage_CreateMaskFromColor (sfImage *Image, sfColor ColorKey, sfUint8 Alpha)
 Create a transparency mask for an image from a specified colorkey.
CSFML_API void sfImage_Copy (sfImage *Image, sfImage *Source, unsigned int DestX, unsigned int DestY, sfIntRect SourceRect)
 Copy pixels from another image onto this one.
CSFML_API sfBool sfImage_CopyScreen (sfImage *Image, sfRenderWindow *Window, sfIntRect SourceRect)
 Create the image from the current contents of the given window.
CSFML_API void sfImage_SetPixel (sfImage *Image, unsigned int X, unsigned int Y, sfColor Color)
 Change the color of a pixel of an image Don't forget to call Update when you end modifying pixels.
CSFML_API sfColor sfImage_GetPixel (sfImage *Image, unsigned int X, unsigned int Y)
 Get a pixel from an image.
CSFML_API const sfUint8 * sfImage_GetPixelsPtr (sfImage *Image)
 Get a read-only pointer to the array of pixels of an image (8 bits integers RGBA) Array size is sfImage_GetWidth() x sfImage_GetHeight() x 4 This pointer becomes invalid if you reload or resize the image.
CSFML_API void sfImage_Bind (sfImage *Image)
 Bind the image for rendering.
CSFML_API void sfImage_SetSmooth (sfImage *Image, sfBool Smooth)
 Enable or disable image smooth filter.
CSFML_API unsigned int sfImage_GetWidth (sfImage *Image)
 Return the width of the image.
CSFML_API unsigned int sfImage_GetHeight (sfImage *Image)
 Return the height of the image.
CSFML_API sfBool sfImage_IsSmooth (sfImage *Image)
 Tells whether the smoothing filter is enabled or not on an image.

Typedef Documentation

typedef struct sfImage sfImage

sfImage is the low-level class for loading and manipulating images

Definition at line 43 of file Image.h.

typedef struct sfRenderWindow sfRenderWindow

Definition at line 36 of file Image.h.


Function Documentation

CSFML_API void sfImage_Bind ( sfImage Image  ) 

Bind the image for rendering.

Parameters:
Image : Image to bind

CSFML_API void sfImage_Copy ( sfImage Image,
sfImage Source,
unsigned int  DestX,
unsigned int  DestY,
sfIntRect  SourceRect 
)

Copy pixels from another image onto this one.

This function does a slow pixel copy and should only be used at initialization time

Parameters:
Image : Destination image
Source : Source image to copy
DestX : X coordinate of the destination position
DestY : Y coordinate of the destination position
SourceRect : Sub-rectangle of the source image to copy

CSFML_API sfBool sfImage_CopyScreen ( sfImage Image,
sfRenderWindow Window,
sfIntRect  SourceRect 
)

Create the image from the current contents of the given window.

Parameters:
Image : Destination image
Window : Window to capture
SourceRect : Sub-rectangle of the screen to copy (empty by default - entire image)
Returns:
True if creation was successful

CSFML_API sfImage* sfImage_Create (  ) 

Create a new empty image.

Returns:
A new sfImage object, or NULL if it failed

CSFML_API sfImage* sfImage_CreateFromColor ( unsigned int  Width,
unsigned int  Height,
sfColor  Color 
)

Create a new image filled with a color.

Parameters:
Width : Image width
Height : Image height
Col : Image color
Returns:
A new sfImage object, or NULL if it failed

CSFML_API sfImage* sfImage_CreateFromFile ( const char *  Filename  ) 

Create a new image from a file.

Parameters:
Filename : Path of the image file to load
Returns:
A new sfImage object, or NULL if it failed

CSFML_API sfImage* sfImage_CreateFromMemory ( const char *  Data,
size_t  SizeInBytes 
)

Create a new image from a file in memory.

Parameters:
Data : Pointer to the file data in memory
SizeInBytes : Size of the data to load, in bytes
Returns:
A new sfImage object, or NULL if it failed

CSFML_API sfImage* sfImage_CreateFromPixels ( unsigned int  Width,
unsigned int  Height,
const sfUint8 *  Data 
)

Create a new image from an array of pixels in memory.

Parameters:
Width : Image width
Height : Image height
Data : Pointer to the pixels in memory (assumed format is RGBA)
Returns:
A new sfImage object, or NULL if it failed

CSFML_API void sfImage_CreateMaskFromColor ( sfImage Image,
sfColor  ColorKey,
sfUint8  Alpha 
)

Create a transparency mask for an image from a specified colorkey.

Parameters:
Image : Image to modify
ColorKey : Color to become transparent
Alpha : Alpha value to use for transparent pixels

CSFML_API void sfImage_Destroy ( sfImage Image  ) 

Destroy an existing image.

Parameters:
Image : Image to delete

CSFML_API unsigned int sfImage_GetHeight ( sfImage Image  ) 

Return the height of the image.

Parameters:
Image : Image to read
Returns:
Height in pixels

CSFML_API sfColor sfImage_GetPixel ( sfImage Image,
unsigned int  X,
unsigned int  Y 
)

Get a pixel from an image.

Parameters:
Image : Image to read
X : X coordinate of pixel in the image
Y : Y coordinate of pixel in the image
Returns:
Color of pixel (x, y)

CSFML_API const sfUint8* sfImage_GetPixelsPtr ( sfImage Image  ) 

Get a read-only pointer to the array of pixels of an image (8 bits integers RGBA) Array size is sfImage_GetWidth() x sfImage_GetHeight() x 4 This pointer becomes invalid if you reload or resize the image.

Parameters:
Image : Image to read
Returns:
Pointer to the array of pixels

CSFML_API unsigned int sfImage_GetWidth ( sfImage Image  ) 

Return the width of the image.

Parameters:
Image : Image to read
Returns:
Width in pixels

CSFML_API sfBool sfImage_IsSmooth ( sfImage Image  ) 

Tells whether the smoothing filter is enabled or not on an image.

Parameters:
Image : Image to read
Returns:
sfTrue if the smoothing filter is enabled

CSFML_API sfBool sfImage_SaveToFile ( sfImage Image,
const char *  Filename 
)

Save the content of an image to a file.

Parameters:
Image : Image to save
Filename : Path of the file to save (overwritten if already exist)
Returns:
sfTrue if saving was successful

CSFML_API void sfImage_SetPixel ( sfImage Image,
unsigned int  X,
unsigned int  Y,
sfColor  Color 
)

Change the color of a pixel of an image Don't forget to call Update when you end modifying pixels.

Parameters:
Image : Image to modify
X : X coordinate of pixel in the image
Y : Y coordinate of pixel in the image
Col : New color for pixel (X, Y)

CSFML_API void sfImage_SetSmooth ( sfImage Image,
sfBool  Smooth 
)

Enable or disable image smooth filter.

Parameters:
Image : Image to modify
Smooth : sfTrue to enable smoothing filter, false to disable it