Exponent::GUI::Graphics::CImageManager Class Reference

List of all members.

Detailed Description

Manages image loaded and getting in an application static wide format
.

CimageManager allows all the image loading for an application to happen in once nice tidy place.
This class is heavily under construction and as such you are advised to *not use it yet!*.

Todo:
Add XML reading
Date:
17/04/2006
Author:
Paul Chana
Version:
1.0.0 Initial version

1.0.1 Added getImageOnPath function

Note:
All contents of this source code are copyright 2005 Exp Digital Uk.
This source file is covered by the licence conditions of the Infinity API. You should have recieved a copy
with the source code. If you didnt, please refer to http://www.expdigital.co.uk All content is the Intellectual property of Exp Digital Uk.
Certain sections of this code may come from other sources. They are credited where applicable.
If you have comments, suggestions or bug reports please visit http://support.expdigital.co.uk
Id
CImageManager.hpp,v 1.8 2007/03/03 02:59:20 paul Exp

Definition at line 44 of file CImageManager.hpp.

Static Public Member Functions

Static Public Attributes

Static Protected Member Functions

Static Protected Attributes

Classes


Member Function Documentation

static bool Exponent::GUI::Graphics::CImageManager::addAnimation ( const CSystemString &  path,
const CString filename,
const CString referenceName,
const long  frameHeight,
const long  numberOfFrames 
) [static]

Add an animation image

Parameters:
path The folder that contains the image
filename The name of the file to load. Currently only TGA 32bpp format is supported
referenceName The name to refere to the image with, this must be unique
frameHeight The height of each frame
numberOfFrames The number of frames in the image
Return values:
bool True if the image was loaded, false otherwise

static bool Exponent::GUI::Graphics::CImageManager::addImage ( const CSystemString &  path,
const CString filename,
const CString referenceName 
) [static]

Add an image to the manager

Parameters:
path The folder that contains the image
filename The name of the file to load. Currently only TGA 32bpp format is supported
referenceName The name to refere to the image with, this must be unique
Return values:
bool True if the image was loaded, false otherwise

static void Exponent::GUI::Graphics::CImageManager::clearImageLibrary (  )  [static]

Remove all the items from the image library

static CImageManager::CAnimationReference* Exponent::GUI::Graphics::CImageManager::getAnimation ( const CString referenceName  )  [static]

Get an animation image with a specific name

Parameters:
referenceName The name of the image
Return values:
CAnimationReference* The image requeseted or null on error

static IImage* Exponent::GUI::Graphics::CImageManager::getAnimation ( const CString referenceName,
long &  frameHeight,
long &  numberOfFrames 
) [static]

Get an animation image with a specific name

Parameters:
referenceName The name of the image
frameHeight On return contains the height of each frame
numberOfFrames On return contains the number of frames in the image
Return values:
IImage * The image requeseted or null on error

static const CSystemString& Exponent::GUI::Graphics::CImageManager::getDefaultPathToImages (  )  [inline, static]

Get the default path

Return values:
const CSystemString& The default image path

Definition at line 237 of file CImageManager.hpp.

References CIMAGE_MANAGER_DEFAULT_RESOURCE_PATH.

static IImage* Exponent::GUI::Graphics::CImageManager::getImage ( const CString referenceName  )  [static]

Get an image with a specific name

Parameters:
referenceName The name of the image
Return values:
IImage * The image requeseted or null on error

static IImage* Exponent::GUI::Graphics::CImageManager::getImageOnPath ( const CSystemString &  path  )  [static]

Get an image from a path

Parameters:
path The path to the image
Return values:
IImage* The image or NULL on error

static CString Exponent::GUI::Graphics::CImageManager::getReferenceNameForImage ( const IImage image  )  [static]

Get a reference name for an image

Parameters:
image The image
Return values:
CString The reference name or CSTRING_EMPTY_STRING on error

static bool Exponent::GUI::Graphics::CImageManager::loadFromDefinitionFile ( const CSystemString &  filename  )  [static]

Load the images from a file
The image manager expects the filename to point to a valid xml document. Each xml document should have (inside the root) two children, one for animations, one for images
The images have 3 tags, The relative path, the filename and the reference name
The animations have five attributes, the 3 above, a frame height (height of each frame in the image list) and a number of frames (total number of frames in animation)
Here is example code to write a definition file

 // Add to a root node
 CXMLNode *root = new CXMLNode(CIMAGE_MANAGER_XML_TAG_ROOT, NULL);
 root->addAttribute(CIMAGE_MANAGER_XML_TAG_VERSION, "1.0.0");               // Currently only one defined. But make sure you include for future usage

 // One image and one animation node
 CXMLNode *images     = new CXMLNode(CIMAGE_MANAGER_XML_TAG_IMAGES,     root);
 CXMLNode *animations = new CXMLNode(CIMAGE_MANAGER_XML_TAG_ANIMATIONS, root);

 // Add our images
 CXMLNode *myImage = new CXMLNode(CIMAGE_MANAGER_XML_TAG_CHILD_IMAGE, images);
 myImage->addAttribute(CIMAGE_MANAGER_XML_ATTRIBUTE_IMAGE_RELATIVE_PATH,  "/Path/To/Place");
 myImage->addAttribute(CIMAGE_MANAGER_XML_ATTRIBUTE_IMAGE_FILENAME,  "MyImage.tga");
 myImage->addAttribute(CIMAGE_MANAGER_XML_ATTRIBUTE_IMAGE_NAME,  "MyImagesName");

 // Add our animations
 CXMLNode *myAnimation = new CXMLNode(CIMAGE_MANAGER_XML_TAG_CHILD_IMAGE, animations);
 myAnimation->addAttribute(CIMAGE_MANAGER_XML_ATTRIBUTE_IMAGE_RELATIVE_PATH, "/Path/To/Place");
 myAnimation->addAttribute(CIMAGE_MANAGER_XML_ATTRIBUTE_IMAGE_FILENAME, "MyImage.tga");
 myAnimation->addAttribute(CIMAGE_MANAGER_XML_ATTRIBUTE_IMAGE_NAME, "MyImagesName");
 myAnimation->addAttribute(CIMAGE_MANAGER_XML_ATTRIBUTE_ANIMATION_FRAME_HEIGHT, "25");
 myAnimation->addAttribute(CIMAGE_MANAGER_XML_ATTRIBUTE_ANIMATION_NUM_FRAMES, "127");
Parameters:
filename The name of the file that contains the image definitons
Return values:
bool True if loaded properly, false otherwise
Note:
THE SYSTEM DESCRIBED BELOW IS NOW DEPRECATED (AND IS INCLUDED FOR BACKWARDS COMPATIBILITY ONLY!), USE THE XML LISTING AS ABOVE
A file is expected to have two parts, animation and images. These parts
can be in any order desired inside the file.
After an identifier (either <animation> or <images>) each line after that must contain
an image or an animation
Images should be declared like this
RelativePath, Filename, ReferenceName
And animations should be declared like this
RelativePath, Filename, ReferenceName, FrameHeight, NumberOfFrames
lines with # symbols at the start are comments and are ignored
Note that if an image is in the root folder, you can use {} for the relative path to signify this

static bool Exponent::GUI::Graphics::CImageManager::readFromXML ( const CSystemString &  filename  )  [static, protected]

Read from an XML document

Parameters:
filename The name of the file to load
Return values:
bool TRue if loaded, false otherwise

static void Exponent::GUI::Graphics::CImageManager::setDefaultPathToImages ( const CSystemString &  defaultPath  )  [static]

Set the default path to images

Parameters:
defaultPath The default path. All added images expect path parameter to be relative to tis position


Member Data Documentation

TCountedPointerArray<CAnimationReference> Exponent::GUI::Graphics::CImageManager::CIMAGE_MANAGER_ANIMATIONS [static, protected]

The array of animation images

Definition at line 372 of file CImageManager.hpp.

CSystemString Exponent::GUI::Graphics::CImageManager::CIMAGE_MANAGER_DEFAULT_RESOURCE_PATH [static, protected]

Default resource path

Definition at line 373 of file CImageManager.hpp.

Referenced by getDefaultPathToImages().

TCountedPointerArray<CImageReference> Exponent::GUI::Graphics::CImageManager::CIMAGE_MANAGER_IMAGES [static, protected]

The array of normal images

Definition at line 371 of file CImageManager.hpp.

const char Exponent::GUI::Graphics::CImageManager::CIMAGE_MANAGER_XML_ATTRIBUTE_ANIMATION_FRAME_HEIGHT[] [static]

The attribute name fot the animations number of frames

Definition at line 61 of file CImageManager.hpp.

const char Exponent::GUI::Graphics::CImageManager::CIMAGE_MANAGER_XML_ATTRIBUTE_ANIMATION_NUM_FRAMES[] [static]

The attribute name fot the animations number of frames

Definition at line 62 of file CImageManager.hpp.

const char Exponent::GUI::Graphics::CImageManager::CIMAGE_MANAGER_XML_ATTRIBUTE_IMAGE_FILENAME[] [static]

The attribute name for the image filename

Definition at line 58 of file CImageManager.hpp.

const char Exponent::GUI::Graphics::CImageManager::CIMAGE_MANAGER_XML_ATTRIBUTE_IMAGE_NAME[] [static]

The attribute name for the image reference

Definition at line 59 of file CImageManager.hpp.

const char Exponent::GUI::Graphics::CImageManager::CIMAGE_MANAGER_XML_ATTRIBUTE_IMAGE_RELATIVE_PATH[] [static]

The attribute name for the image relative path

Definition at line 57 of file CImageManager.hpp.

const char Exponent::GUI::Graphics::CImageManager::CIMAGE_MANAGER_XML_TAG_ANIMATIONS[] [static]

The tag used to start the animations block

Definition at line 54 of file CImageManager.hpp.

const char Exponent::GUI::Graphics::CImageManager::CIMAGE_MANAGER_XML_TAG_CHILD_IMAGE[] [static]

The tag used to declare an image

Definition at line 56 of file CImageManager.hpp.

const char Exponent::GUI::Graphics::CImageManager::CIMAGE_MANAGER_XML_TAG_IMAGES[] [static]

The tag used to start the images block

Definition at line 53 of file CImageManager.hpp.

const char Exponent::GUI::Graphics::CImageManager::CIMAGE_MANAGER_XML_TAG_ROOT[] [static]

The tag used for the root of an image xml file

Definition at line 51 of file CImageManager.hpp.

const char Exponent::GUI::Graphics::CImageManager::CIMAGE_MANAGER_XML_TAG_VERSION[] [static]

Version of the XML file

Definition at line 52 of file CImageManager.hpp.


Infinity API - Exponent::GUI::Graphics::CImageManager Class Reference generated on 7 Mar 2007