103 explicit Image(
const std::filesystem::path& filename);
120 Image(
const void* data, std::size_t size);
175 [[nodiscard]]
bool loadFromFile(
const std::filesystem::path& filename);
227 [[nodiscard]]
bool saveToFile(
const std::filesystem::path& filename)
const;
245 [[nodiscard]] std::optional<std::vector<std::uint8_t>>
saveToMemory(std::string_view format)
const;
365 std::vector<std::uint8_t> m_pixels;
#define SFML_GRAPHICS_API
Utility class for manipulating RGBA colors.
static const Color Black
Black predefined color.
Color getPixel(Vector2u coords) const
Get the color of a pixel.
bool loadFromStream(InputStream &stream)
Load the image from a custom stream.
Image(const std::filesystem::path &filename)
Construct the image from a file on disk.
bool saveToFile(const std::filesystem::path &filename) const
Save the image to a file on disk.
Image(Vector2u size, const std::uint8_t *pixels)
Construct the image from an array of pixels.
bool copy(const Image &source, Vector2u dest, const IntRect &sourceRect={}, bool applyAlpha=false)
Copy pixels from another image onto this one.
void flipHorizontally()
Flip the image horizontally (left <-> right)
std::optional< std::vector< std::uint8_t > > saveToMemory(std::string_view format) const
Save the image to a buffer in memory.
Image(const void *data, std::size_t size)
Construct the image from a file in memory.
void createMaskFromColor(Color color, std::uint8_t alpha=0)
Create a transparency mask from a specified color-key.
void flipVertically()
Flip the image vertically (top <-> bottom)
Vector2u getSize() const
Return the size (width and height) of the image.
const std::uint8_t * getPixelsPtr() const
Get a read-only pointer to the array of pixels.
Image()=default
Default constructor.
void resize(Vector2u size, const std::uint8_t *pixels)
Resize the image from an array of pixels.
bool loadFromMemory(const void *data, std::size_t size)
Load the image from a file in memory.
Image(Vector2u size, Color color=Color::Black)
Construct the image and fill it with a unique color.
bool loadFromFile(const std::filesystem::path &filename)
Load the image from a file on disk.
Image(InputStream &stream)
Construct the image from a custom stream.
void setPixel(Vector2u coords, Color color)
Change the color of a pixel.
void resize(Vector2u size, Color color=Color::Black)
Resize the image and fill it with a unique color.
Vector2< unsigned int > Vector2u