31#include <SFML/System/Resource.hpp>
32#include <SFML/Graphics/Color.hpp>
33#include <SFML/Graphics/Rect.hpp>
72 Image(
unsigned int Width,
unsigned int Height,
const Color& Col =
Color(0, 0, 0, 255));
82 Image(
unsigned int Width,
unsigned int Height,
const Uint8* Data);
121 bool LoadFromPixels(
unsigned int Width,
unsigned int Height,
const Uint8* Data);
131 bool SaveToFile(
const std::string& Filename)
const;
143 bool Create(
unsigned int Width,
unsigned int Height,
Color Col =
Color(0, 0, 0, 255));
166 void Copy(
const Image& Source,
unsigned int DestX,
unsigned int DestY,
const IntRect& SourceRect = IntRect(0, 0, 0, 0),
bool ApplyAlpha =
false);
188 void SetPixel(
unsigned int X,
unsigned int Y,
const Color& Col);
289 bool CreateTexture();
295 void EnsureTextureUpdate()
const;
301 void EnsureArrayUpdate()
const;
313 void DestroyTexture();
318 unsigned int myWidth;
319 unsigned int myHeight;
320 unsigned int myTextureWidth;
321 unsigned int myTextureHeight;
322 unsigned int myTexture;
324 mutable std::vector<Color> myPixels;
325 mutable bool myNeedTextureUpdate;
326 mutable bool myNeedArrayUpdate;
Color is an utility class for manipulating 32-bits RGBA colors.
unsigned int GetHeight() const
Return the height of the image.
void Bind() const
Bind the image for rendering.
bool SaveToFile(const std::string &Filename) const
Save the content of the image to a file.
const Uint8 * GetPixelsPtr() const
Get a read-only pointer to the array of pixels (RGBA 8 bits integers components) Array size is GetWid...
void Copy(const Image &Source, unsigned int DestX, unsigned int DestY, const IntRect &SourceRect=IntRect(0, 0, 0, 0), bool ApplyAlpha=false)
Copy pixels from another image onto this one.
bool Create(unsigned int Width, unsigned int Height, Color Col=Color(0, 0, 0, 255))
Create an empty image.
void SetPixel(unsigned int X, unsigned int Y, const Color &Col)
Change the color of a pixel.
bool LoadFromPixels(unsigned int Width, unsigned int Height, const Uint8 *Data)
Load the image directly from an array of pixels.
unsigned int GetWidth() const
Return the width of the image.
bool LoadFromMemory(const char *Data, std::size_t SizeInBytes)
Load the image from a file in memory.
const Color & GetPixel(unsigned int X, unsigned int Y) const
Get a pixel from the image.
bool LoadFromFile(const std::string &Filename)
Load the image from a file.
bool CopyScreen(RenderWindow &Window, const IntRect &SourceRect=IntRect(0, 0, 0, 0))
Create the image from the current contents of the given window.
static unsigned int GetValidTextureSize(unsigned int Size)
Get a valid texture size according to hardware support.
Image()
Default constructor.
FloatRect GetTexCoords(const IntRect &Rect) const
Convert a subrect expressed in pixels, into float texture coordinates.
void SetSmooth(bool Smooth)
Enable or disable image smooth filter.
bool IsSmooth() const
Tells whether the smooth filtering is enabled or not.
void CreateMaskFromColor(Color ColorKey, Uint8 Alpha=0)
Create transparency mask from a specified colorkey.
Rect is an utility class for manipulating rectangles.
Simple wrapper for sf::Window that allows easy 2D rendering.
Window is a rendering window ; it can create a new window or connect to an existing one.