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

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 Mng Movie 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
 
virtual bool isDirty () const
 

Static Public Member Functions

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

Protected Member Functions

 Image ()
 

Protected Attributes

voidmData
 
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() [1/3]

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() [2/3]

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

Constructor.

Parameters
filenamethe filename of the image.
Exceptions
Exceptionwhen no ImageLoader exists.

◆ ~Image()

Image::~Image ( )
virtual

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

◆ Image() [3/3]

Image::Image ( )
protected

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

Member Function Documentation

◆ _getData()

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 Mng, CGraphic, and Movie.

◆ _getImageLoader()

ImageLoader * Image::_getImageLoader ( )
static

Gets the ImageLoader used for loading Images.

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

◆ getHeight()

int Image::getHeight ( ) const
virtual

Gets the height of the Image.

Returns
the image height

Reimplemented in Mng, CGraphic, and Movie.

◆ getWidth()

int Image::getWidth ( ) const
virtual

Gets the width of the Image.

Returns
the image width

Reimplemented in Mng, CGraphic, and Movie.

◆ isDirty()

virtual bool gcn::Image::isDirty ( ) const
inlinevirtual

Reimplemented in Mng, and Movie.

◆ setImageLoader()

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

◆ mData

void* gcn::Image::mData
protected

◆ mHeight

int gcn::Image::mHeight
protected

◆ mImageLoader

ImageLoader * Image::mImageLoader = NULL
staticprotected

◆ mLoadedWithImageLoader

bool gcn::Image::mLoadedWithImageLoader
protected

◆ mWidth

int gcn::Image::mWidth
protected

The documentation for this class was generated from the following files:
gcn::Image::setImageLoader
static void setImageLoader(ImageLoader *imageLoader)
Definition: image.cpp:118
(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.