sf::Image Class Reference

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

#include <Image.hpp>

Inheritance diagram for sf::Image:

sf::VideoResource List of all members.

Public Member Functions

 Image ()
 Default constructor.
 Image (const Image &Copy)
 Copy constructor.
 Image (unsigned int Width, unsigned int Height, const Color &Col=Color(0, 0, 0, 255))
 Construct an empty image.
 Image (unsigned int Width, unsigned int Height, const void *Data)
 Construct the image from pixels in memory.
 ~Image ()
 Destructor.
bool LoadFromFile (const std::string &Filename)
 Load the image 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 Color &Col=Color(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 Color &ColorKey, Uint8 Alpha=0)
 Create transparency mask from a specified colorkey.
void Resize (unsigned int Width, unsigned int Height, const Color &Col=Color(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 Color &Col)
 Change the color of a pixel Don't forget to call Update when you end modifying pixels.
Color GetPixel (unsigned int X, unsigned int Y) const
 Get a pixel from the image.
const Uint32 * 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 the whole image in video memory.
void Bind () const
 Bind the image for rendering.
void SetSmooth (bool Smooth) const
 Enable or disable image smoothing 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.
FloatRect GetTexCoords (const IntRect &Rect) const
 Convert a subrect expressed in pixels, into float texture coordinates.
Imageoperator= (const Image &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

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

Definition at line 44 of file Image.hpp.


Constructor & Destructor Documentation

sf::Image::Image (  ) 

Default constructor.

Definition at line 43 of file Image.cpp.

sf::Image::Image ( const Image Copy  ) 

Copy constructor.

Parameters:
Copy : instance to copy

Definition at line 57 of file Image.cpp.

sf::Image::Image ( unsigned int  Width,
unsigned int  Height,
const Color Col = Color(0, 0, 0, 255) 
)

Construct an empty image.

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

Definition at line 73 of file Image.cpp.

sf::Image::Image ( 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 87 of file Image.cpp.

sf::Image::~Image (  ) 

Destructor.

Definition at line 101 of file Image.cpp.


Member Function Documentation

bool sf::Image::LoadFromFile ( const std::string &  Filename  ) 

Load the image from a file.

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

Definition at line 111 of file Image.cpp.

bool sf::Image::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 141 of file Image.cpp.

void sf::Image::Create ( unsigned int  Width,
unsigned int  Height,
const Color Col = Color(0, 0, 0, 255) 
)

Create an empty image.

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

Definition at line 151 of file Image.cpp.

void sf::Image::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 169 of file Image.cpp.

void sf::Image::CreateMaskFromColor ( const Color ColorKey,
Uint8  Alpha = 0 
)

Create transparency mask from a specified colorkey.

Parameters:
ColorKey : Color to become transparent
Alpha : Alpha value to use for transparent pixels (0 by default)

Definition at line 195 of file Image.cpp.

void sf::Image::Resize ( unsigned int  Width,
unsigned int  Height,
const Color Col = Color(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
Col : Color to assign to new pixels (black by default)

Definition at line 213 of file Image.cpp.

void sf::Image::SetPixel ( unsigned int  X,
unsigned int  Y,
const Color Col 
)

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
Col : New color for pixel (X, Y)

Definition at line 244 of file Image.cpp.

Color sf::Image::GetPixel ( unsigned int  X,
unsigned int  Y 
) const

Get a pixel from the image.

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

Definition at line 261 of file Image.cpp.

const Uint32 * sf::Image::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 280 of file Image.cpp.

void sf::Image::Update (  ) 

Update the whole image in video memory.

Definition at line 297 of file Image.cpp.

void sf::Image::Bind (  )  const

Bind the image for rendering.

Definition at line 312 of file Image.cpp.

void sf::Image::SetSmooth ( bool  Smooth  )  const

Enable or disable image smoothing filter.

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

Definition at line 326 of file Image.cpp.

void sf::Image::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 343 of file Image.cpp.

unsigned int sf::Image::GetWidth (  )  const

Return the width of the image.

Returns:
Width in pixels

Definition at line 359 of file Image.cpp.

unsigned int sf::Image::GetHeight (  )  const

Return the height of the image.

Returns:
Height in pixels

Definition at line 368 of file Image.cpp.

FloatRect sf::Image::GetTexCoords ( const IntRect 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 378 of file Image.cpp.

unsigned int sf::Image::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 390 of file Image.cpp.

Image & sf::Image::operator= ( const Image Other  ) 

Assignment operator.

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

Definition at line 412 of file Image.cpp.


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