sfImage Class Reference

#include <Image.hpp>

List of all members.

Public Member Functions

 sfImage ()
 sfImage (unsigned int Width, unsigned int Height, const sfColor &Color=sfColor::Black)
 sfImage (unsigned int Width, unsigned int Height, const void *Data)
bool LoadFromFile (const std::string &Filename)
bool SaveToFile (const std::string &Filename) const
void Create (unsigned int Width, unsigned int Height, const sfColor &Color=sfColor::Black)
void LoadFromMemory (unsigned int Width, unsigned int Height, const void *Data)
void CreateMaskFromColor (const sfColor &ColorKey)
void Resize (unsigned int Width, unsigned int Height, const sfColor &Color=sfColor::Black)
void SetPixel (unsigned int X, unsigned int Y, const sfColor &Color)
sfColor GetPixel (unsigned int X, unsigned int Y) const
const sfUint32 * GetPixelsPtr () const
void Update ()
void Bind () const
void SetSmooth (bool Smooth) const
void SetRepeat (bool Repeat) const
unsigned int GetWidth () const
unsigned int GetHeight () const
sfFloatRect GetTexCoords (const sfIntRect &Rect) const

Static Public Member Functions

static unsigned int GetValidTextureSize (unsigned int Size)


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 37 of file Image.cpp.

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

Construct an empty image

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

Definition at line 46 of file Image.cpp.

References Create().

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 56 of file Image.cpp.

References LoadFromMemory().


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 66 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 89 of file Image.cpp.

Referenced by sfRenderWindow::Capture().

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

Create an empty image

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

Definition at line 101 of file Image.cpp.

References sfColor::ToRGBA().

Referenced by LoadFromMemory(), and sfImage().

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 114 of file Image.cpp.

References Create(), and sfColor::White.

Referenced by sfImage().

void sfImage::CreateMaskFromColor ( const sfColor ColorKey  ) 

Create transparency mask from a specified colorkey

Parameters:
ColorKey : Color to become transparent

Definition at line 136 of file Image.cpp.

References sfColor::ToRGBA().

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

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 154 of file Image.cpp.

References GetHeight(), GetWidth(), and sfColor::ToRGBA().

Referenced by sfPostFX::Render().

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 183 of file Image.cpp.

References GetHeight(), GetWidth(), and sfColor::ToRGBA().

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 208 of file Image.cpp.

References sfColor::Black, GetHeight(), and GetWidth().

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 234 of file Image.cpp.

void sfImage::Update (  ) 

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

Definition at line 251 of file Image.cpp.

void sfImage::Bind (  )  const

Bind the image for rendering

Definition at line 261 of file Image.cpp.

Referenced by sfSprite::Render(), and sfPostFX::Render().

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 271 of file Image.cpp.

Referenced by sfPostFX::Render().

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 282 of file Image.cpp.

Referenced by sfPostFX::Render().

unsigned int sfImage::GetWidth (  )  const

Return the width of the image

Returns:
Width in pixels

Definition at line 292 of file Image.cpp.

Referenced by GetPixel(), sfSprite::Render(), sfPostFX::Render(), Resize(), and SetPixel().

unsigned int sfImage::GetHeight (  )  const

Return the height of the image

Returns:
Height in pixels

Definition at line 301 of file Image.cpp.

Referenced by GetPixel(), sfSprite::Render(), sfPostFX::Render(), Resize(), and SetPixel().

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 311 of file Image.cpp.

Referenced by sfSprite::Render(), and sfPostFX::Render().

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 320 of file Image.cpp.


The documentation for this class was generated from the following files:
Generated for SFML by  doxygen 1.5.2