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

gcn::Image Class Reference

#include <image.h>

Inheritance diagram for gcn::Image:

CGraphic CPlayerColorGraphic

List of all members.


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:
data the data of the image.
width the width of the image.
height the height of the image.

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

Constructor.

Parameters:
filename the filename of the image.
Exceptions:
Exception when 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

int Image::getWidth (  )  const [virtual]

Gets the width of the Image.

Returns:
the image width

Reimplemented in CGraphic.

int Image::getHeight (  )  const [virtual]

Gets the height of the Image.

Returns:
the image height

Reimplemented in CGraphic.

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

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


Member Data Documentation

void* gcn::Image::mData [protected]

int gcn::Image::mWidth [protected]

int gcn::Image::mHeight [protected]

ImageLoader * Image::mImageLoader = NULL [static, protected]


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