Colobot
|
Image loaded from file. More...
#include <image.h>
Public Member Functions | |
CImage () | |
Constructs empty image (with NULL data) | |
CImage (Math::IntPoint size) | |
Constructs a RGBA image of given size. | |
virtual | ~CImage () |
Destroys image, calling Free() | |
void | Free () |
Frees the allocated image data. | |
bool | IsEmpty () const |
Returns whether the image is empty (has null data) | |
ImageData * | GetData () |
Returns the image data; if empty - returns nullptr. | |
Math::IntPoint | GetSize () const |
Returns the image size. | |
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. | |
bool | Load (const std::string &fileName) |
Loads an image from the specified file. | |
bool | SavePNG (const std::string &fileName) |
Saves the image to the specified file in PNG format. | |
std::string | GetError () |
Returns the last error. | |
void | flipVertically () |
Flips the image vertically. | |
void | SetDataPixels (void *pixels) |
sets/replaces the pixels from the surface | |
Image loaded from file.
Wrapper around SDL_Image library to load images. Also contains function for saving images to PNG.
void CImage::Fill | ( | Gfx::IntColor | color | ) |
Fills the whole image with given color.
Image must be valid.
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::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 |