Colobot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | List of all members
CImage Class Reference

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)
 
ImageDataGetData ()
 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
 

Detailed Description

Image loaded from file.

Wrapper around SDL_Image library to load images. Also contains function for saving images to PNG.

Member Function Documentation

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.

Parameters
pixelpixel coords (range x: 0..width-1 y: 0..height-1)
Returns
color
Gfx::IntColor CImage::GetPixelInt ( Math::IntPoint  pixel)

Returns the precise color at given pixel.

Image must be valid and pixel coords in valid range.

Parameters
pixelpixel coords (range x: 0..width-1 y: 0..height-1)
Returns
color
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.

Parameters
pixelpixel coords (range x: 0..width-1 y: 0..height-1)
colorcolor
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.

Parameters
pixelpixel coords (range x: 0..width-1 y: 0..height-1)
colorcolor

The documentation for this class was generated from the following files: