Colobot
|
Image loaded from file. More...
#include <image.h>
Public Member Functions | |
CImage () | |
Constructs empty image (with nullptr data) More... | |
CImage (Math::IntPoint size) | |
Constructs a RGBA image of given size. More... | |
virtual | ~CImage () |
Destroys image, calling Free() More... | |
CImage (const CImage &other)=delete | |
void | operator= (const CImage &other)=delete |
void | Free () |
Frees the allocated image data. More... | |
bool | IsEmpty () const |
Returns whether the image is empty (has null data) More... | |
ImageData * | GetData () |
Returns the image data; if empty - returns nullptr. More... | |
Math::IntPoint | GetSize () const |
Returns the image size. More... | |
void | Fill (Gfx::IntColor color) |
Fills the whole image with given color. More... | |
void | SetPixel (Math::IntPoint pixel, Gfx::Color color) |
Sets the color at given pixel. More... | |
void | SetPixelInt (Math::IntPoint pixel, Gfx::IntColor color) |
Sets the precise color at given pixel. More... | |
Gfx::Color | GetPixel (Math::IntPoint pixel) |
Returns the color at given pixel. More... | |
Gfx::IntColor | GetPixelInt (Math::IntPoint pixel) |
Returns the precise color at given pixel. More... | |
void | PadToNearestPowerOfTwo () |
Pads the image to nearest power of 2 dimensions. More... | |
void | ConvertToRGBA () |
Convert the image to RGBA surface. More... | |
bool | Load (const std::string &fileName) |
Loads an image from the specified file. More... | |
bool | SavePNG (const std::string &fileName) |
Saves the image to the specified file in PNG format. More... | |
std::string | GetError () |
Returns the last error. More... | |
void | FlipVertically () |
Flips the image vertically. More... | |
void | SetDataPixels (void *pixels) |
sets/replaces the pixels from the surface More... | |
Image loaded from file.
Wrapper around SDL_Image library to load images. Also contains function for saving images to PNG.
CImage::CImage | ( | ) |
Constructs empty image (with nullptr data)
CImage::CImage | ( | Math::IntPoint | size | ) |
Constructs a RGBA image of given size.
|
virtual |
Destroys image, calling Free()
void CImage::Free | ( | ) |
Frees the allocated image data.
bool CImage::IsEmpty | ( | ) | const |
Returns whether the image is empty (has null data)
ImageData * CImage::GetData | ( | ) |
Returns the image data; if empty - returns nullptr.
Math::IntPoint CImage::GetSize | ( | ) | const |
Returns the image size.
void CImage::Fill | ( | Gfx::IntColor | color | ) |
Fills the whole image with given color.
Image must be valid.
void CImage::SetPixel | ( | Math::IntPoint | pixel, |
Gfx::Color | color | ||
) |
Sets the color at given pixel.
Image must be valid and pixel coords in valid range.
pixel | pixel coords (range x: 0..width-1 y: 0..height-1) |
color | color |
void CImage::SetPixelInt | ( | Math::IntPoint | pixel, |
Gfx::IntColor | color | ||
) |
Sets the precise color at given pixel.
Image must be valid and pixel coords in valid range.
pixel | pixel coords (range x: 0..width-1 y: 0..height-1) |
color | color |
Gfx::Color CImage::GetPixel | ( | Math::IntPoint | pixel | ) |
Returns the color at given pixel.
Image must be valid and pixel coords in valid range.
pixel | pixel coords (range x: 0..width-1 y: 0..height-1) |
Gfx::IntColor CImage::GetPixelInt | ( | Math::IntPoint | pixel | ) |
Returns the precise color at given pixel.
Image must be valid and pixel coords in valid range.
pixel | pixel coords (range x: 0..width-1 y: 0..height-1) |
void CImage::PadToNearestPowerOfTwo | ( | ) |
Pads the image to nearest power of 2 dimensions.
Image must be valid.
The dimensions are increased to nearest even power of two values. If image is already in power-of-two format, nothing is done.
void CImage::ConvertToRGBA | ( | ) |
Convert the image to RGBA surface.
bool CImage::Load | ( | const std::string & | fileName | ) |
Loads an image from the specified file.
bool CImage::SavePNG | ( | const std::string & | fileName | ) |
Saves the image to the specified file in PNG format.
std::string CImage::GetError | ( | ) |
Returns the last error.
void CImage::FlipVertically | ( | ) |
Flips the image vertically.
void CImage::SetDataPixels | ( | void * | pixels | ) |
sets/replaces the pixels from the surface