Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members  

csImageFile Class Reference

An abstract class representing an abstract image. More...

#include <csimage.h>

Inheritance diagram for csImageFile:

iImage iBase csImageMemory List of all members.

Public Methods

virtual ~csImageFile ()
 Destroy the image file object and free all associated storage.

virtual void* GetImageData ()
 Get image data: returns either (csRGBpixel *) or (unsigned char *) depending on format. More...

virtual int GetWidth ()
 Query image width.

virtual int GetHeight ()
 Query image height.

virtual int GetSize ()
 Query image size in bytes.

virtual void Rescale (int newwidth, int newheight)
 Rescale the image to the given size.

virtual iImageMipMap (int step, csRGBpixel *transp)
 Create a new csImageFile which is a mipmapped version of this one. More...

virtual void SetName (const char *iName)
 Set image file name.

virtual const char* GetName ()
 Get image file name.

virtual int GetFormat ()
 Get image format.

virtual csRGBpixelGetPalette ()
 Get image palette (or NULL if no palette).

virtual uint8* GetAlpha ()
 Get alpha map for image.

virtual void SetFormat (int iFormat)
 Convert the image to another format.

virtual iImageClone ()
 Create yet another image and copy this one into the new image.

virtual iImageCrop (int x, int y, int width, int height)
 Create another image and copy a subpart of this image into the new image.

virtual void CheckAlpha ()
 Check if all alpha values are "non-transparent" and if so, discard alpha.

virtual bool HasKeycolor ()
 check if image has a keycolour stored with it.

virtual void GetKeycolor (int &r, int &g, int &b)
 get the keycolour stored with the image.


Public Attributes

 SCF_DECLARE_IBASE

Protected Methods

 csImageFile (int iFormat)
 csImageFile constructor. More...

void set_dimensions (int w, int h)
 Set the width and height. More...

void convert_rgba (csRGBpixel *iImage)
 Used to convert an truecolor RGB image into requested format. More...

void convert_pal8 (uint8 *iImage, csRGBpixel *iPalette, int nPalColors=256)
 Used to convert an 8-bit indexed image into requested format. More...

void convert_pal8 (uint8 *iImage, csRGBcolor *iPalette, int nPalColors=256)
 Same as above but accepts an array of csRGBcolor's as palette. More...

void FreeImage ()
 Free all image data: pixels and palette. More...

int closest_index (csRGBpixel *iColor)
 Return the closest color index to given. Fails if image has no palette.


Protected Attributes

int Width
 Width of image.

int Height
 Height of image.

void* Image
 The image data.

csRGBpixelPalette
 The image palette or NULL.

uint8* Alpha
 The alpha map.

char* fName
 Image file name.

int Format
 Image format (see CS_IMGFMT_XXX above).

uint8 has_keycolour
 if it has a keycolour, and the keycolour values.

uint8 keycolour_r
 if it has a keycolour, and the keycolour values.

uint8 keycolour_g
 if it has a keycolour, and the keycolour values.

uint8 keycolour_b
 if it has a keycolour, and the keycolour values.


Detailed Description

An abstract class representing an abstract image.

For every image type supported, a subclass should be created for loading that image type. The image file class contains a number of member functions for accessing and manipulating the image contents.


Constructor & Destructor Documentation

csImageFile::csImageFile ( int iFormat ) [protected]
 

csImageFile constructor.

This object can only be created by an appropriate loader, which is why the constructor is protected.


Member Function Documentation

void csImageFile::FreeImage ( ) [protected]
 

Free all image data: pixels and palette.

Takes care of image data format.

void * csImageFile::GetImageData ( ) [virtual]
 

Get image data: returns either (csRGBpixel *) or (unsigned char *) depending on format.

Note that for RGBA images the csRGBpixel structure contains the alpha channel as well, so GetAlpha (see below) method will return NULL (because alpha is not stored separately, as for paletted images).

Reimplemented from iImage.

iImage * csImageFile::MipMap ( int step,
csRGBpixel * transp ) [virtual]
 

Create a new csImageFile which is a mipmapped version of this one.

'step' indicates how much the mipmap should be scaled down. Only steps 0, 1, 2, and 3 are supported. Step 0 returns the blended version of the image without image being scaled down. The new image will have same format as the original one. If you pass a pointer to a transparent color, the texels of that color are handled differently.

Reimplemented from iImage.

void csImageFile::convert_pal8 ( uint8 * iImage,
csRGBcolor * iPalette,
int nPalColors = 256 ) [protected]
 

Same as above but accepts an array of csRGBcolor's as palette.

The csRGBcolor array is never freed, so its your responsability if you did it.

void csImageFile::convert_pal8 ( uint8 * iImage,
csRGBpixel * iPalette,
int nPalColors = 256 ) [protected]
 

Used to convert an 8-bit indexed image into requested format.

Pass a pointer to color indices and a pointer to palette, and you're done. NOTE: the pointer should be allocated with new uint8 [] and you should not free it after calling this function: the function will free the buffer itself if it is appropiate (or wont if the buffer size/contents are appropiate for target format). Same about palette.

void csImageFile::convert_rgba ( csRGBpixel * iImage ) [protected]
 

Used to convert an truecolor RGB image into requested format.

If the image loader cannot handle conversion itself, and the image file is in a format that is different from the requested one, load the image in csRGBpixel format and pass the pointer to this function which will handle the RGB -> target format conversion. NOTE: the pointer should be allocated with new csRGBpixel [] and you should not free it after calling this function: the function will free the buffer itself if it is appropiate (or wont if the buffer size/contents are appropiate for target format).

void csImageFile::set_dimensions ( int w,
int h ) [protected]
 

Set the width and height.

This will also free the 'image' buffer to hold the bitmap, but it will NOT allocate a new buffer (thus `image' is NULL after calling this function). You should pass an appropiate pointer to one of convert_xxx functions below to define the image itself (or assign something to `image' manually).


The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000