CrystalSpace

Public API Reference

csImageMemory Class Reference
[Graphics]

Memory image. More...

#include <csgfx/imagememory.h>

Inherits scfImplementationExt0< csImageMemory, csImageBase >.

Inherited by scfImplementationExt0< csCommonImageFile, csImageMemory >, and scfImplementationExt0< csCommonImageFile, csImageMemory >.

List of all members.

Public Member Functions

virtual void ApplyKeyColor ()
 Apply the keycolor, that is, set all pixels which match the keycolor to 0.
void CheckAlpha ()
 Check if all alpha values are "non-transparent" and if so, discard alpha.
void Clear (const csRGBpixel &colour)
 Clears image to colour. Only works for truecolor images.
virtual void ClearKeyColor ()
 Remove the keycolor.
void ConvertFromPal8 (uint8 *iImage, uint8 *alpha, csRGBpixel *iPalette, int nPalColors=256)
 Used to convert an 8-bit indexed image into requested format.
void ConvertFromPal8 (uint8 *iImage, uint8 *alpha, const csRGBcolor *iPalette, int nPalColors=256)
 Used to convert an 8-bit indexed image into requested format.
void ConvertFromRGBA (csRGBpixel *iImage)
 Used to convert an truecolor RGB image into requested format.
bool Copy (iImage *srcImage, int x, int y, int width, int height)
 Copy an image as subpart into this image.
bool CopyScale (iImage *srcImage, int x, int y, int width, int height)
 Copy an image as subpart into this image with scaling sImage to the given size.
bool CopyTile (iImage *srcImage, int x, int y, int width, int height)
 Copy an image as subpart into this image and tile and scale sImage to the given size.
 csImageMemory (int width, int height, void *buffer, bool destroy, int format=CS_IMGFMT_TRUECOLOR, csRGBpixel *palette=0)
 Create an instance for this pixel buffer with these dimensions.
 csImageMemory (int width, int height, int format=CS_IMGFMT_TRUECOLOR)
 Create a blank image of these dimensions and the specified format.
 csImageMemory (int width, int height, const void *buffer, int format=CS_IMGFMT_TRUECOLOR, const csRGBpixel *palette=0)
 Create an instance from a pixel buffer with these dimensions.
 csImageMemory (iImage *source)
 Create an instance that copies the pixel data from another iImage object.
 csImageMemory (int width, int height, int depth, int format)
 Create a blank image of these dimensions and the specified format.
 csImageMemory (iImage *source, int newFormat)
 Create an instance that copies the pixel data from another iImage object, and also change the data format.
uint8GetAlphaPtr ()
 Get a pointer to the alpha data that can be changed.
void * GetImagePtr ()
 Get a pointer to the image data that can be changed.
csRGBpixelGetPalettePtr ()
 Get a pointer to the palette data that can be changed.
void SetFormat (int iFormat)
 Convert the image to another format.
virtual void SetKeyColor (int r, int g, int b)
 Set the keycolor.
bool SetMipmap (uint num, iImage *mip)
 Set a mipmap of this image.

Protected Member Functions

void AllocImage ()
 Allocate the pixel data buffers.
 csImageMemory (int iFormat)
 csImageMemory constructor, only set a format, no dimensions.
void EnsureImage ()
 Allocate the pixel data buffers if they aren't already.
void FreeImage ()
 Free all image data: pixels and palette.
void SetDimensions (int newWidth, int newHeight)
 Set the width and height.

Protected Attributes

uint8Alpha
 The alpha map.
csRef< iDataBufferdatabuf
 The image data.
int Depth
 Depth of image.
bool destroy_image
 If true when these interfaces are destroyed the image is also.
int Format
 Image format (see CS_IMGFMT_XXX above).
bool has_keycolour
 if it has a keycolour.
int Height
 Height of image.
csImageType imageType
 Type of the contained images.
csRGBpixel keycolour
 keycolour value
csArray< csRef< iImage > > mipmaps
 Mip map images.
csRGBpixelPalette
 The image palette or 0.
int Width
 Width of image.

Detailed Description

Memory image.

Definition at line 40 of file imagememory.h.


Constructor & Destructor Documentation

csImageMemory::csImageMemory ( int  iFormat  )  [protected]

csImageMemory constructor, only set a format, no dimensions.

Intended to be used by loaders which later call SetDimensions().

csImageMemory::csImageMemory ( int  width,
int  height,
int  format = CS_IMGFMT_TRUECOLOR 
)

Create a blank image of these dimensions and the specified format.

Parameters:
width Width of the image
height Height of the image
format Image format. Default: CS_IMGFMT_TRUECOLOR
csImageMemory::csImageMemory ( int  width,
int  height,
int  depth,
int  format 
)

Create a blank image of these dimensions and the specified format.

Parameters:
width Width of the image
height Height of the image
depth Height of the image
format Image format.
csImageMemory::csImageMemory ( int  width,
int  height,
void *  buffer,
bool  destroy,
int  format = CS_IMGFMT_TRUECOLOR,
csRGBpixel palette = 0 
)

Create an instance for this pixel buffer with these dimensions.

If destroy is set to true then the supplied buffer will be destroyed when the instance is.

Parameters:
width Width of the image
height Height of the image
buffer Data containing initial data
destroy Destroy the buffer when the Image is destroyed
format Image format. Data in

palette Palette for indexed images.
csImageMemory::csImageMemory ( int  width,
int  height,
const void *  buffer,
int  format = CS_IMGFMT_TRUECOLOR,
const csRGBpixel palette = 0 
)

Create an instance from a pixel buffer with these dimensions.

A copy of the pixel data is made.

Parameters:
width Width of the image
height Height of the image
buffer Data containing initial data
format Image format. Data in

palette Palette for indexed images.
csImageMemory::csImageMemory ( iImage source  ) 

Create an instance that copies the pixel data from another iImage object.

csImageMemory::csImageMemory ( iImage source,
int  newFormat 
)

Create an instance that copies the pixel data from another iImage object, and also change the data format.


Member Function Documentation

void csImageMemory::AllocImage (  )  [protected]

Allocate the pixel data buffers.

virtual void csImageMemory::ApplyKeyColor (  )  [virtual]

Apply the keycolor, that is, set all pixels which match the keycolor to 0.

void csImageMemory::CheckAlpha (  ) 

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

void csImageMemory::Clear ( const csRGBpixel colour  ) 

Clears image to colour. Only works for truecolor images.

virtual void csImageMemory::ClearKeyColor (  )  [virtual]

Remove the keycolor.

void csImageMemory::ConvertFromPal8 ( uint8 iImage,
uint8 alpha,
csRGBpixel iPalette,
int  nPalColors = 256 
)

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

Pass a pointer to color indices, a pointer to the alpha mask and a pointer to the 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 appropriate (or wont if the buffer size/contents are appropriate for target format). Same about palette and alpha.

void csImageMemory::ConvertFromPal8 ( uint8 iImage,
uint8 alpha,
const csRGBcolor iPalette,
int  nPalColors = 256 
)

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

Pass a pointer to color indices, a pointer to the alpha mask and a pointer to the 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 appropriate (or wont if the buffer size/contents are appropriate for target format). Same about palette and alpha.

void csImageMemory::ConvertFromRGBA ( csRGBpixel iImage  ) 

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 appropriate (or wont if the buffer size/contents are appropriate for target format).

bool csImageMemory::Copy ( iImage srcImage,
int  x,
int  y,
int  width,
int  height 
)

Copy an image as subpart into this image.

bool csImageMemory::CopyScale ( iImage srcImage,
int  x,
int  y,
int  width,
int  height 
)

Copy an image as subpart into this image with scaling sImage to the given size.

bool csImageMemory::CopyTile ( iImage srcImage,
int  x,
int  y,
int  width,
int  height 
)

Copy an image as subpart into this image and tile and scale sImage to the given size.

void csImageMemory::EnsureImage (  )  [protected]

Allocate the pixel data buffers if they aren't already.

void csImageMemory::FreeImage (  )  [protected]

Free all image data: pixels and palette.

Takes care of image data format.

uint8* csImageMemory::GetAlphaPtr (  ) 

Get a pointer to the alpha data that can be changed.

void* csImageMemory::GetImagePtr (  ) 

Get a pointer to the image data that can be changed.

csRGBpixel* csImageMemory::GetPalettePtr (  ) 

Get a pointer to the palette data that can be changed.

void csImageMemory::SetDimensions ( int  newWidth,
int  newHeight 
) [protected]

Set the width and height.

This will also free the 'image' buffer to hold the pixel data, 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 ConvertXXX functions below, define the image itself (or assign something to `Image' manually), or call EnsureImage().

void csImageMemory::SetFormat ( int  iFormat  ) 

Convert the image to another format.

This method will allocate a respective color component if it was not allocated before. For example, you can use this method to add alpha channel to paletted images, to allocate a image for CS_IMGFMT_NONE alphamaps or vice versa, to remove the image and leave alphamap alone. This routine may be used as well for removing alpha channel.

virtual void csImageMemory::SetKeyColor ( int  r,
int  g,
int  b 
) [virtual]

Set the keycolor.

bool csImageMemory::SetMipmap ( uint  num,
iImage mip 
) [inline]

Set a mipmap of this image.

Remarks:
You can set any mipmap except number 0 to your liking, however, no sanity checking is performed! That is, you can set mipmaps to 0, leave out mipmaps and provide more mipmaps than the image really needs - this can be problematic as most clients will expect non-null mipmaps. (Note however that trailing 0 mipmaps will not be reported.)

Definition at line 258 of file imagememory.h.


Member Data Documentation

The alpha map.

Definition at line 70 of file imagememory.h.

The image data.

A value of 0 means the Image contents are "undefined". However, this is an internal state only. No operation should fail due undefined image data (although the data may stay undefined).

Definition at line 66 of file imagememory.h.

int csImageMemory::Depth [protected]

Depth of image.

Definition at line 59 of file imagememory.h.

bool csImageMemory::destroy_image [protected]

If true when these interfaces are destroyed the image is also.

Definition at line 78 of file imagememory.h.

int csImageMemory::Format [protected]

Image format (see CS_IMGFMT_XXX above).

Definition at line 72 of file imagememory.h.

bool csImageMemory::has_keycolour [protected]

if it has a keycolour.

Definition at line 74 of file imagememory.h.

int csImageMemory::Height [protected]

Height of image.

Definition at line 57 of file imagememory.h.

Type of the contained images.

Definition at line 80 of file imagememory.h.

keycolour value

Definition at line 76 of file imagememory.h.

Mip map images.

Definition at line 85 of file imagememory.h.

The image palette or 0.

Definition at line 68 of file imagememory.h.

int csImageMemory::Width [protected]

Width of image.

Definition at line 55 of file imagememory.h.


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

Generated for Crystal Space 1.4.1 by doxygen 1.7.1