gcn::Image Class Reference

#include <image.hpp>

Inheritance diagram for gcn::Image:

gcn::AllegroImage gcn::HGEImage gcn::OpenGLImage gcn::OpenLayerImage 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 might crash in a most bizarre way.

See also:
AllegroImageLoader, HGEImageLoader, OpenLayerImageLoader, OpenGLAllegroImageLoader, OpenGLSDLImageLoader, SDLImageLoader
Since:
0.1.0

Definition at line 83 of file image.hpp.

Public Member Functions

virtual void convertToDisplayFormat ()=0
 Converts the image, if possible, to display format.
virtual void free ()=0
 Frees an 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 int getWidth () const=0
 Gets the width of the image.
 Image ()
 Constructor.
virtual void putPixel (int x, int y, const Color &color)=0
 Puts a pixel with a certain color at coordinate (x, y).
virtual ~Image ()
 Destructor.

Static Public Member Functions

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

Static Protected Attributes

static ImageLoadermImageLoader = NULL
 Holds the image loader to be used when loading images.


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.

Since:
0.5.0

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

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

virtual void gcn::Image::free (  )  [pure virtual]

Frees an image.

Since:
0.5.0

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

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

Gets the height of the image.

Returns:
The height of the image.
Since:
0.1.0

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

Referenced by gcn::ImageButton::draw(), gcn::Icon::draw(), gcn::HGEGraphics::drawImage(), gcn::Graphics::drawImage(), gcn::Icon::Icon(), gcn::ImageButton::ImageButton(), gcn::ImageFont::ImageFont(), and gcn::ImageFont::scanForGlyph().

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

Gets the image loader used for loading images.

Returns:
The image loader used for loading images.
See also:
setImageLoader, AllegroImageLoader, HGEImageLoader, OpenLayerImageLoader, OpenGLAllegroImageLoader, OpenGLSDLImageLoader, SDLImageLoader
Since:
0.1.0

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.
Since:
0.5.0

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

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

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

Gets the width of the image.

Returns:
The width of the image.
Since:
0.1.0

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

Referenced by gcn::ImageButton::draw(), gcn::Icon::draw(), gcn::HGEGraphics::drawImage(), gcn::Graphics::drawImage(), gcn::Icon::Icon(), gcn::ImageButton::ImageButton(), gcn::ImageFont::ImageFont(), and gcn::ImageFont::scanForGlyph().

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

Loads an image by using the class' image laoder.

All image loaders implemented in Guichan 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:
filename The file to load.
convertToDisplayFormat True if the image should be converted to display, false otherwise.
Since:
0.5.0

Definition at line 89 of file image.cpp.

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

Referenced by gcn::Icon::Icon(), gcn::ImageButton::ImageButton(), and 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.
Since:
0.5.0

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

void gcn::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:
imageLoader The image loader to be used for loading images.
See also:
getImageLoader, AllegroImageLoader, HGEImageLoader, OpenLayerImageLoader, OpenGLAllegroImageLoader, OpenGLSDLImageLoader, SDLImageLoader
Since:
0.1.0

Definition at line 79 of file image.cpp.

References mImageLoader.


The documentation for this class was generated from the following files:
Generated on Sun Jan 20 21:48:15 2008 for Guichan by  doxygen 1.5.2