FifeGUI 0.2.0
A C++ GUI library designed for games.
fcn::Image Class Referenceabstract

#include <image.hpp>

Inheritance diagram for fcn::Image:
fcn::opengl::Image fcn::sdl2::Image

Public Member Functions

virtual void convertToDisplayFormat ()=0
virtual void free ()=0
virtual int getHeight () const =0
virtual Color getPixel (int x, int y)=0
virtual int getWidth () const =0
 Image (Image &&)=delete
 Image (Image const &)=delete
Image & operator= (Image &&)=delete
Image & operator= (Image const &)=delete
virtual void putPixel (int x, int y, Color const &color)=0

Static Public Member Functions

static ImageLoadergetImageLoader ()
static Image * load (std::string const &filename, bool convertToDisplayFormat=true)
static void setImageLoader (ImageLoader *imageLoader)

Static Protected Attributes

static ImageLoadermImageLoader = nullptr

Detailed Description

Abstract holder for image data.

To be able to use this class you must first set an ImageLoader in Image by calling

Image::setImageLoader(myImageLoader)
static void setImageLoader(ImageLoader *imageLoader)
Sets the ImageLoader to be used for loading images.
Definition image.cpp:21

The function is static. If this is not done, the constructor taking a filename will throw an exception. The ImageLoader you use must be compatible with the Graphics object you use.

See also
OpenGLSDLImageLoader, SDLImageLoader

Definition at line 31 of file image.hpp.

Member Function Documentation

◆ convertToDisplayFormat()

virtual void fcn::Image::convertToDisplayFormat ( )
pure virtual

Converts the image, if possible, to display format.

IMPORTANT: Only guaranteed to work before the image has been converted to display format.

Implemented in fcn::opengl::Image, and fcn::sdl2::Image.

Referenced by load().

◆ free()

virtual void fcn::Image::free ( )
pure virtual

Frees an image.

Implemented in fcn::opengl::Image, and fcn::sdl2::Image.

◆ getHeight()

virtual int fcn::Image::getHeight ( ) const
pure virtual

Gets the height of the image.

Returns
The height of the image.

Implemented in fcn::opengl::Image, and fcn::sdl2::Image.

Referenced by fcn::ImageButton::adjustSizeImpl(), and fcn::Graphics::drawImage().

◆ getImageLoader()

ImageLoader * fcn::Image::getImageLoader ( )
static

Gets the image loader used for loading images.

Returns
The image loader used for loading images.
See also
setImageLoader, OpenGLSDLImageLoader, SDLImageLoader

Definition at line 26 of file image.cpp.

References mImageLoader.

◆ getPixel()

virtual Color fcn::Image::getPixel ( int x,
int y )
pure virtual

Gets the color of a pixel at coordinate (x, y) in the image.

IMPORTANT: Only guaranteed to work before the image has been converted to display format.

Parameters
xThe x coordinate.
yThe y coordinate.
Returns
The color of the pixel.

Implemented in fcn::opengl::Image, and fcn::sdl2::Image.

◆ getWidth()

virtual int fcn::Image::getWidth ( ) const
pure virtual

Gets the width of the image.

Returns
The width of the image.

Implemented in fcn::opengl::Image, and fcn::sdl2::Image.

Referenced by fcn::CheckBox::adjustSizeImpl(), fcn::ImageButton::adjustSizeImpl(), fcn::Graphics::drawImage(), and fcn::CheckBox::drawMarkerImage().

◆ load()

Image * fcn::Image::load ( std::string const & filename,
bool convertToDisplayFormat = true )
static

Loads an image by using the class' image loader.

All image loaders implemented in FifeGUI return a newly instantiated image which must be deleted in order to avoid a memory leak.

NOTE: The functions getPixel and putPixel are only guaranteed to work before an image has been converted to display format.

Parameters
filenameThe file to load.
convertToDisplayFormatTrue if the image should be converted to display, false otherwise.

Definition at line 31 of file image.cpp.

References convertToDisplayFormat(), and mImageLoader.

Referenced by fcn::CheckBox::setBackgroundImage(), fcn::Icon::setImage(), and fcn::ImageButton::setImage().

◆ putPixel()

virtual void fcn::Image::putPixel ( int x,
int y,
Color const & color )
pure virtual

Puts a pixel with a certain color at coordinate (x, y).

Parameters
xThe x coordinate.
yThe y coordinate.
colorThe color of the pixel to put.

Implemented in fcn::opengl::Image, and fcn::sdl2::Image.

◆ setImageLoader()

void fcn::Image::setImageLoader ( ImageLoader * imageLoader)
static

Sets the ImageLoader to be used for loading images.

IMPORTANT: The image loader is static and MUST be set before loading images!

Parameters
imageLoaderThe image loader to be used for loading images.
See also
getImageLoader, OpenGLSDLImageLoader, SDLImageLoader

Definition at line 21 of file image.cpp.

References mImageLoader.

Member Data Documentation

◆ mImageLoader

ImageLoader * fcn::Image::mImageLoader = nullptr
staticprotected

Holds the image loader to be used when loading images.

Definition at line 132 of file image.hpp.

Referenced by getImageLoader(), load(), and setImageLoader().


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