Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

gcn::Image Class Reference

#include <image.hpp>

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 76 of file image.hpp.

Public Member Functions

 Image (void *data, int width, int height)
 Constructor.
 Image (const std::string &filename)
 Constructor.
virtual ~Image ()
 Destructor.
virtual int getWidth () const
 Gets the width of the Image.
virtual int getHeight () const
 Gets the height of the Image.
virtual void * _getData () const
 Gets the data of the Image.

Static Public Member Functions

static ImageLoader_getImageLoader ()
 Gets the ImageLoader used for loading Images.
static void setImageLoader (ImageLoader *imageLoader)
 Sets the ImageLoader to be used for loading images.

Protected Member Functions

 Image ()
 Default constructor.

Protected Attributes

void * mData
int mWidth
int mHeight
bool mLoadedWithImageLoader

Static Protected Attributes

static ImageLoadermImageLoader = NULL


Constructor & Destructor Documentation

gcn::Image::Image void *  data,
int  width,
int  height
 

Constructor.

Parameters:
data the data of the image.
width the width of the image.
height the height of the image.

Definition at line 72 of file image.cpp.

gcn::Image::Image const std::string &  filename  ) 
 

Constructor.

Parameters:
filename the filename of the image.
Exceptions:
Exception when no ImageLoader exists.

Definition at line 80 of file image.cpp.

References gcn::ImageLoader::finalize(), gcn::ImageLoader::getHeight(), gcn::ImageLoader::getWidth(), and gcn::ImageLoader::prepare().

gcn::Image::~Image  )  [virtual]
 

Destructor.

Unloads the image with the ImageLoader, if it was loaded with it.

Definition at line 94 of file image.cpp.

References gcn::ImageLoader::free().

gcn::Image::Image  )  [protected]
 

Default constructor.

It is protected so you can inherit from this class.

Definition at line 67 of file image.cpp.


Member Function Documentation

void * gcn::Image::_getData  )  const [virtual]
 

Gets the data of the Image.

Image data can be different things depending on what ImageLoader you use. If you for instance use the SDLImageLoader then an SDL_Surface will be returned.

Returns:
a void pointer to the Image data.
See also:
SDLImageLoader, AllegroImageLoader

Definition at line 112 of file image.cpp.

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 122 of file image.cpp.

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

Gets the height of the Image.

Returns:
the image height

Definition at line 107 of file image.cpp.

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

Gets the width of the Image.

Returns:
the image width

Definition at line 102 of file image.cpp.

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 117 of file image.cpp.


The documentation for this class was generated from the following files:
Generated on Tue May 17 21:23:26 2005 for Guichan by  doxygen 1.4.1