#include <csimage.h>
Inheritance diagram for csImageFile:
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 iImage* | MipMap (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 csRGBpixel* | GetPalette () |
Get image palette (or NULL if no palette). | |
virtual UByte* | GetAlpha () |
Get alpha map for image. | |
virtual void | SetFormat (int iFormat) |
Convert the image to another format. | |
virtual iImage* | Clone () |
Create yet another image and copy this one into the new image. | |
virtual iImage* | Crop (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 (UByte *iImage, csRGBpixel *iPalette, int nPalColors=256) |
Used to convert an 8-bit indexed image into requested format. More... | |
void | convert_pal8 (UByte *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. | |
csRGBpixel* | Palette |
The image palette or NULL. | |
UByte* | 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. |
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.
|
csImageFile constructor. This object can only be created by an appropriate loader, which is why the constructor is protected. |
|
Free all image data: pixels and palette. Takes care of image data format. |
|
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. |
|
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. |
|
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. |
|
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 UByte [] 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. |
|
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). |
|
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). |