_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
gcn::Image Class Reference

#include <image.h>

Inheritance diagram for gcn::Image:
CGraphic CPlayerColorGraphic

Public Member Functions

 Image (void *data, int width, int height)
 
 Image (const std::string &filename)
 
virtual ~Image ()
 
virtual int getWidth () const
 
virtual int getHeight () const
 
virtual void * _getData () const
 

Static Public Member Functions

static ImageLoader_getImageLoader ()
 
static void setImageLoader (ImageLoader *imageLoader)
 

Protected Member Functions

 Image ()
 

Protected Attributes

void * mData
 
int mWidth
 
int mHeight
 
bool mLoadedWithImageLoader
 

Static Protected Attributes

static ImageLoadermImageLoader = NULL
 

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.

Constructor & Destructor Documentation

Image::Image ( void *  data,
int  width,
int  height 
)

Constructor.

Parameters
datathe data of the image.
widththe width of the image.
heightthe height of the image.
Image::Image ( const std::string &  filename)

Constructor.

Parameters
filenamethe filename of the image.
Exceptions
Exceptionwhen no ImageLoader exists.
Image::~Image ( )
virtual

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

Image::Image ( )
protected

Default constructor. It is protected so you can inherit from this class.

Member Function Documentation

void * 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

Reimplemented in CGraphic.

ImageLoader * Image::_getImageLoader ( )
static

Gets the ImageLoader used for loading Images.

Returns
the ImageLoader used for loading Images.
See also
SDLImageLoader, AllegroImageLoader
int Image::getHeight ( ) const
virtual

Gets the height of the Image.

Returns
the image height

Reimplemented in CGraphic.

int Image::getWidth ( ) const
virtual

Gets the width of the Image.

Returns
the image width

Reimplemented in CGraphic.

void 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
imageLoaderthe ImageLoader to be used for loading images.
See also
SDLImageLoader, AllegroImageLoader

Member Data Documentation

void* gcn::Image::mData
protected
int gcn::Image::mHeight
protected
ImageLoader * Image::mImageLoader = NULL
staticprotected
bool gcn::Image::mLoadedWithImageLoader
protected
int gcn::Image::mWidth
protected

The documentation for this class was generated from the following files:
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.