gcn::Image Class Reference

#include <image.hpp>

Inheritance diagram for gcn::Image:

gcn::AllegroImage gcn::OpenGLImage gcn::SDLImage List of all members.

Detailed Description

Holds an image.

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

 Image::setImageLoader(myImageLoader) 
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.

EXAMPLE: If you use SDLGraphics you should use SDLImageLoader. Otherwise your program will crash in a most bizarre way.

Definition at line 80 of file image.hpp.

Public Member Functions

 Image ()
 Constructor.
virtual ~Image ()
 Destructor.
virtual void free ()=0
 Frees an image.
virtual int getWidth () const =0
 Gets the width of the Image.
virtual int getHeight () const =0
 Gets the height of the Image.
virtual Color getPixel (int x, int y)=0
 Gets the color of a pixel at coordinate (x, y) in the image.
virtual void putPixel (int x, int y, const Color &color)=0
 Puts a pixel with a certain color at coordinate (x, y).
virtual void convertToDisplayFormat ()=0
 Converts the image, if possible, to display format.

Static Public Member Functions

static Imageload (const std::string &filename, bool convertToDisplayFormat=true)
 Loads an image by calling the Image class' ImageLoader.
static ImageLoadergetImageLoader ()
 Gets the ImageLoader used for loading Images.
static void setImageLoader (ImageLoader *imageLoader)
 Sets the ImageLoader to be used for loading images.

Static Protected Attributes

static ImageLoadermImageLoader = NULL


Member Function Documentation

virtual void gcn::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 gcn::AllegroImage, gcn::OpenGLImage, and gcn::SDLImage.

Referenced by gcn::ImageFont::ImageFont(), gcn::SDLImageLoader::load(), and gcn::AllegroImageLoader::load().

virtual int gcn::Image::getHeight (  )  const [pure virtual]

Gets the height of the Image.

Returns:
the image height

Implemented in gcn::AllegroImage, gcn::OpenGLImage, and gcn::SDLImage.

Referenced by gcn::ImageFont::addGlyph(), gcn::Graphics::drawImage(), gcn::Icon::Icon(), and gcn::ImageFont::ImageFont().

ImageLoader * gcn::Image::getImageLoader (  )  [static]

Gets the ImageLoader used for loading Images.

Returns:
the ImageLoader used for loading Images.
See also:
SDLImageLoader, AllegroImageLoader

Definition at line 84 of file image.cpp.

References mImageLoader.

virtual Color gcn::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:
x the x coordinate.
y the y coordinate.
Returns:
the color of the pixel.

Implemented in gcn::AllegroImage, gcn::OpenGLImage, and gcn::SDLImage.

Referenced by gcn::ImageFont::addGlyph(), and gcn::ImageFont::ImageFont().

virtual int gcn::Image::getWidth (  )  const [pure virtual]

Gets the width of the Image.

Returns:
the image width

Implemented in gcn::AllegroImage, gcn::OpenGLImage, and gcn::SDLImage.

Referenced by gcn::ImageFont::addGlyph(), gcn::Graphics::drawImage(), gcn::Icon::Icon(), and gcn::ImageFont::ImageFont().

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

Loads an image by calling the Image class' ImageLoader.

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

Parameters:
filename the file to load.
convertToDisplayFormat true if the image should be converted to display, false otherwise.

Definition at line 89 of file image.cpp.

References gcn::ImageLoader::load(), and mImageLoader.

Referenced by gcn::ImageFont::ImageFont().

virtual void gcn::Image::putPixel ( int  x,
int  y,
const Color color 
) [pure virtual]

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

Parameters:
x the x coordinate.
y the y coordinate.
color the color of the pixel to put.

Implemented in gcn::AllegroImage, gcn::OpenGLImage, and gcn::SDLImage.

void gcn::Image::setImageLoader ( ImageLoader imageLoader  )  [static]

Sets the ImageLoader to be used for loading images.

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

Parameters:
imageLoader the ImageLoader to be used for loading images.
See also:
SDLImageLoader, AllegroImageLoader

Definition at line 79 of file image.cpp.

References mImageLoader.


The documentation for this class was generated from the following files:
Generated on Sat Jul 29 19:38:48 2006 for Guichan by  doxygen 1.4.7