sfImage Class Reference

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

#include <Image.hpp>

Inheritance diagram for sfImage:

List of all members.

Public Member Functions

 sfImage ()
 Default constructor.
 sfImage (const sfImage &Copy)
 Copy constructor.
 sfImage (unsigned int Width, unsigned int Height, const sfColor &Color=sfColor(0, 0, 0, 255))
 Construct an empty image.
 sfImage (unsigned int Width, unsigned int Height, const void *Data)
 Construct the image from pixels in memory.
 ~sfImage ()
 Destructor.
bool LoadFromFile (const std::string &Filename)
 Load the surface from a file.
bool SaveToFile (const std::string &Filename) const
 Save the content of the image to a file.
void Create (unsigned int Width, unsigned int Height, const sfColor &Color=sfColor(0, 0, 0, 255))
 Create an empty image.
void LoadFromMemory (unsigned int Width, unsigned int Height, const void *Data)
 Load the image from pixels in memory.
void CreateMaskFromColor (const sfColor &ColorKey)
 Create transparency mask from a specified colorkey.
void Resize (unsigned int Width, unsigned int Height, const sfColor &Color=sfColor(0, 0, 0, 255))
 Resize the image - warning : this function does not scale the image, it just ajdusts size (add padding or remove pixels).
void SetPixel (unsigned int X, unsigned int Y, const sfColor &Color)
 Change the color of a pixel Don't forget to call Update when you end modifying pixels.
sfColor GetPixel (unsigned int X, unsigned int Y) const
 Get a pixel from the image.
const sfUint32 * GetPixelsPtr () const
 Get a read-only pointer to the array of pixels (32 bits integer RGBA) Array size is GetWidth() x GetHeight() This pointer becomes invalid if you reload or resize the image.
void Update ()
 Update image in video memory (use when you have modified pixels manually).
void Bind () const
 Bind the image for rendering.
void SetSmooth (bool Smooth) const
 Enable or disable image smooth filter.
void SetRepeat (bool Repeat) const
 Enable or disable image repeat mode (ie.
unsigned int GetWidth () const
 Return the width of the image.
unsigned int GetHeight () const
 Return the height of the image.
sfFloatRect GetTexCoords (const sfIntRect &Rect) const
 Convert a subrect expressed in pixels, into float texture coordinates.
sfImageoperator= (const sfImage &Other)
 Assignment operator.

Static Public Member Functions

static unsigned int GetValidTextureSize (unsigned int Size)
 Get a valid texture size according to hardware support.

Detailed Description

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

Definition at line 42 of file Image.hpp.


Constructor & Destructor Documentation

sfImage::sfImage (  ) 

Default constructor.

Definition at line 41 of file Image.cpp.

sfImage::sfImage ( const sfImage Copy  ) 

Copy constructor.

Parameters:
Copy : instance to copy

Definition at line 55 of file Image.cpp.

sfImage::sfImage ( unsigned int  Width,
unsigned int  Height,
const sfColor Color = sfColor(0, 0, 0, 255) 
)

Construct an empty image.

Parameters:
Width : Image width
Height : Image height
Color : Image color (black by default)

Definition at line 70 of file Image.cpp.

sfImage::sfImage ( unsigned int  Width,
unsigned int  Height,
const void *  Data 
)

Construct the image from pixels in memory.

Parameters:
Width : Image width
Height : Image height
Data : Pointer to the pixels in memory (assumed format is RGBA 32 bits)

Definition at line 84 of file Image.cpp.

sfImage::~sfImage (  ) 

Destructor.

Definition at line 98 of file Image.cpp.


Member Function Documentation

bool sfImage::LoadFromFile ( const std::string &  Filename  ) 

Load the surface from a file.

Parameters:
Filename : Path of the image file to load
Returns:
True if loading was successful

Definition at line 108 of file Image.cpp.

bool sfImage::SaveToFile ( const std::string &  Filename  )  const

Save the content of the image to a file.

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

Definition at line 138 of file Image.cpp.

void sfImage::Create ( unsigned int  Width,
unsigned int  Height,
const sfColor Color = sfColor(0, 0, 0, 255) 
)

Create an empty image.

Parameters:
Width : Image width
Height : Image height
Color : Image color (black by default)

Definition at line 148 of file Image.cpp.

void sfImage::LoadFromMemory ( unsigned int  Width,
unsigned int  Height,
const void *  Data 
)

Load the image from pixels in memory.

Parameters:
Width : Image width
Height : Image height
Data : Pointer to the pixels in memory (assumed format is RGBA 32 bits)

Definition at line 166 of file Image.cpp.

void sfImage::CreateMaskFromColor ( const sfColor ColorKey  ) 

Create transparency mask from a specified colorkey.

Parameters:
ColorKey : Color to become transparent

Definition at line 192 of file Image.cpp.

void sfImage::Resize ( unsigned int  Width,
unsigned int  Height,
const sfColor Color = sfColor(0, 0, 0, 255) 
)

Resize the image - warning : this function does not scale the image, it just ajdusts size (add padding or remove pixels).

Parameters:
Width : New width
Height : New height
Color : Color to assign to new pixels (black by default)

Definition at line 210 of file Image.cpp.

void sfImage::SetPixel ( unsigned int  X,
unsigned int  Y,
const sfColor Color 
)

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

Parameters:
X : X coordinate of pixel in the image
Y : Y coordinate of pixel in the image
Color : New color for pixel (X, Y)

Definition at line 241 of file Image.cpp.

sfColor sfImage::GetPixel ( unsigned int  X,
unsigned int  Y 
) const

Get a pixel from the image.

Parameters:
X : Path of the image file to load
Y : Path of the image file to load
Returns:
Color of pixel (x, y)

Definition at line 258 of file Image.cpp.

const sfUint32 * sfImage::GetPixelsPtr (  )  const

Get a read-only pointer to the array of pixels (32 bits integer RGBA) Array size is GetWidth() x GetHeight() This pointer becomes invalid if you reload or resize the image.

Returns:
Const pointer to the array of pixels

Definition at line 277 of file Image.cpp.

void sfImage::Update (  ) 

Update image in video memory (use when you have modified pixels manually).

Definition at line 294 of file Image.cpp.

void sfImage::Bind (  )  const

Bind the image for rendering.

Definition at line 309 of file Image.cpp.

void sfImage::SetSmooth ( bool  Smooth  )  const

Enable or disable image smooth filter.

Parameters:
Smooth : True to enable smoothing filter, false to disable it

Definition at line 320 of file Image.cpp.

void sfImage::SetRepeat ( bool  Repeat  )  const

Enable or disable image repeat mode (ie.

how to define pixels outside the texture range)

Parameters:
Repeat : True to enable repeat, false to disable

Definition at line 337 of file Image.cpp.

unsigned int sfImage::GetWidth (  )  const

Return the width of the image.

Returns:
Width in pixels

Definition at line 353 of file Image.cpp.

unsigned int sfImage::GetHeight (  )  const

Return the height of the image.

Returns:
Height in pixels

Definition at line 362 of file Image.cpp.

sfFloatRect sfImage::GetTexCoords ( const sfIntRect Rect  )  const

Convert a subrect expressed in pixels, into float texture coordinates.

Parameters:
Rect : Sub-rectangle of image to convert
Returns:
Texture coordinates corresponding to the sub-rectangle

Definition at line 372 of file Image.cpp.

unsigned int sfImage::GetValidTextureSize ( unsigned int  Size  )  [static]

Get a valid texture size according to hardware support.

Parameters:
Size : Size to convert
Returns:
Valid nearest size (greater than or equal to specified size)

Definition at line 384 of file Image.cpp.

sfImage & sfImage::operator= ( const sfImage Other  ) 

Assignment operator.

Parameters:
Other : instance to assign
Returns:
Reference to the image

Definition at line 406 of file Image.cpp.


The documentation for this class was generated from the following files: