CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

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.

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 csPtr< iImageMipMap (int step, csRGBpixel *transp)
 Create a new csImageFile which is a mipmapped version of this one.

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 0 if no palette).

virtual uint8GetAlpha ()
 Get alpha map for image.

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

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

virtual csPtr< 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.

virtual csPtr< iImageSharpen (csRGBpixel *transp, int strength)
 Create a sharpened copy of the image.

virtual int HasMipmaps ()
 Returns the number of mipmaps contained in the image (in case there exist any precalculated mipmaps.


Protected Methods

 csImageFile (int iFormat)
 csImageFile constructor.

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

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

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

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

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

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 0.

uint8Alpha
 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.

Definition at line 36 of file csimage.h.


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.

virtual csImageFile::~csImageFile   [virtual]
 

Destroy the image file object and free all associated storage.


Member Function Documentation

virtual void csImageFile::CheckAlpha   [virtual]
 

Check if all alpha values are "non-transparent" and if so, discard alpha.

Implements iImage.

virtual csPtr<iImage> csImageFile::Clone   [virtual]
 

Create yet another image and copy this one into the new image.

Implements iImage.

int csImageFile::closest_index csRGBpixel   iColor [protected]
 

Return the closest color index to given. Fails if image has no palette.

void csImageFile::convert_pal8 uint8   iImage,
const 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).

virtual csPtr<iImage> csImageFile::Crop int    x,
int    y,
int    width,
int    height
[virtual]
 

Create another image and copy a subpart of this image into the new image.

Implements iImage.

virtual void csImageFile::FreeImage   [protected, virtual]
 

Free all image data: pixels and palette.

Takes care of image data format.

Reimplemented in csImageMemory.

virtual uint8* csImageFile::GetAlpha   [virtual]
 

Get alpha map for image.

Implements iImage.

virtual int csImageFile::GetFormat   [virtual]
 

Get image format.

Implements iImage.

virtual int csImageFile::GetHeight   [virtual]
 

Query image height.

Implements iImage.

virtual 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 0 (because alpha is not stored separately, as for paletted images).

Implements iImage.

virtual void csImageFile::GetKeycolor int &    r,
int &    g,
int &    b
[virtual]
 

get the keycolour stored with the image.

Implements iImage.

virtual const char* csImageFile::GetName   [virtual]
 

Get image file name.

Implements iImage.

virtual csRGBpixel* csImageFile::GetPalette   [virtual]
 

Get image palette (or 0 if no palette).

Implements iImage.

virtual int csImageFile::GetSize   [virtual]
 

Query image size in bytes.

Implements iImage.

virtual int csImageFile::GetWidth   [virtual]
 

Query image width.

Implements iImage.

virtual bool csImageFile::HasKeycolor   [virtual]
 

check if image has a keycolour stored with it

Implements iImage.

virtual int csImageFile::HasMipmaps   [virtual]
 

Returns the number of mipmaps contained in the image (in case there exist any precalculated mipmaps.

Implements iImage.

virtual csPtr<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. Step 0 returns a blurred version of the image without image being scaled down. Step 1 scales the image down to 1/2. Steps > 1 repeat this 'step' times. 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.

Implements iImage.

virtual void csImageFile::Rescale int    newwidth,
int    newheight
[virtual]
 

Rescale the image to the given size.

Implements iImage.

Reimplemented in csImageMemory.

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 0 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).

virtual void csImageFile::SetFormat int    iFormat [virtual]
 

Convert the image to another format.

Implements iImage.

virtual void csImageFile::SetName const char *    iName [virtual]
 

Set image file name.

Implements iImage.

virtual csPtr<iImage> csImageFile::Sharpen csRGBpixel   transp,
int    strength
[virtual]
 

Create a sharpened copy of the image.

Implements iImage.


Member Data Documentation

uint8* csImageFile::Alpha [protected]
 

The alpha map.

Definition at line 48 of file csimage.h.

char* csImageFile::fName [protected]
 

Image file name.

Definition at line 50 of file csimage.h.

int csImageFile::Format [protected]
 

Image format (see CS_IMGFMT_XXX above).

Definition at line 52 of file csimage.h.

uint8 csImageFile::has_keycolour [protected]
 

if it has a keycolour, and the keycolour values.

Definition at line 54 of file csimage.h.

int csImageFile::Height [protected]
 

Height of image.

Definition at line 42 of file csimage.h.

void* csImageFile::Image [protected]
 

The image data.

Definition at line 44 of file csimage.h.

uint8 csImageFile::keycolour_b [protected]
 

if it has a keycolour, and the keycolour values.

Definition at line 54 of file csimage.h.

uint8 csImageFile::keycolour_g [protected]
 

if it has a keycolour, and the keycolour values.

Definition at line 54 of file csimage.h.

uint8 csImageFile::keycolour_r [protected]
 

if it has a keycolour, and the keycolour values.

Definition at line 54 of file csimage.h.

csRGBpixel* csImageFile::Palette [protected]
 

The image palette or 0.

Definition at line 46 of file csimage.h.

int csImageFile::Width [protected]
 

Width of image.

Definition at line 40 of file csimage.h.


The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.2.18