____                _       __
    / __ )____  _____   | |     / /___ ___________
   / __  / __ \/ ___/   | | /| / / __ `/ ___/ ___/
  / /_/ / /_/ (__  )    | |/ |/ / /_/ / /  (__  )
 /_____/\____/____/     |__/|__/\__,_/_/  /____/

       A futuristic real-time strategy game.
          This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project. Distributed under the "GNU General Public License"

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.

Definition at line 76 of file image.h.


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.

References mData, mHeight, mLoadedWithImageLoader, and mWidth.

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_EXCEPTION, gcn::ImageLoader::getHeight(), gcn::ImageLoader::getWidth(), mData, mHeight, mImageLoader, mLoadedWithImageLoader, mWidth, 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(), mImageLoader, and mLoadedWithImageLoader.

gcn::Image::Image (  )  [protected]

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

Definition at line 67 of file image.cpp.

References mLoadedWithImageLoader.


Member Function Documentation

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

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

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

Reimplemented in CGraphic.

Definition at line 112 of file image.cpp.

References mData.

Referenced by gcn::SDLGraphics::drawImage().

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.

References mImageLoader.

Referenced by gcn::ImageFont::addGlyph(), gcn::ImageFont::ImageFont(), and gcn::ImageFont::~ImageFont().

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.

References mImageLoader.


Member Data Documentation

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

Definition at line 152 of file image.h.

Referenced by _getData(), and Image().

int gcn::Image::mWidth [protected]

Definition at line 153 of file image.h.

Referenced by getWidth(), and Image().

int gcn::Image::mHeight [protected]

Definition at line 154 of file image.h.

Referenced by getHeight(), and Image().

Definition at line 155 of file image.h.

Referenced by Image(), and ~Image().

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

Definition at line 156 of file image.h.

Referenced by _getImageLoader(), Image(), setImageLoader(), and ~Image().


The documentation for this class was generated from the following files:

Generated on Sat Feb 21 00:28:26 2009 for Bos Wars by  doxygen 1.5.6