Product Home Class IndexDownload

CK_StaticImage

CK_Object
   |
   +----CK_Image
           |
           +----CK_StaticImage

This class represents a single, non-animated image loaded from a file. Factory methods exist to create an image from .pcx, .bmp, or .cim files. A .cim file is a serialized CK_StaticImage object.

CK_StaticImage objects cannot be drawn to the display. This is because the pixel data might not be stored in the same format (i.e. bits/pixel) as the display surface. The CK_Bitmap class represents a bitmap stored in the correct pixel format. A CK_Bitmap object can be created from a CK_StaticImage regardless of the display's pixel format, or the pixel format of the CK_StaticImage. As an example, if an application wanted to display an image stored in a .pcx file, it would first create a CK_StaticImage object from the .pcx file. It would then create a CK_Bitmap from the CK_StaticImage, effectively converting from the .pcx pixel depth, to the pixel depth of the display surface.

See CK_Image for more information.


Factory Methods

create
Create a CK_StaticImage object from an opened file pointer.
createFromFile
Creates a CK_StaticImage object from a file.
createFromResource
Creates a CK_StaticImage object from a BMP file stored as a resource. (v1.02)

Inherited Methods

appendPalette
Adds a palette to the image's palette set.
deletePalette
Delets a palette from the image's palette set.
extractPaletteSet
Removes the palette set from the image. The image will no longer have any palette information.
getCompression
Returns the compression object, if any, installed with this instance.
getHeight
Returns the height in pixels of the image.
getNumPalettes
Returns the number of palettes in the image's palette set, if any.
getPaletteSet
Returns a const pointer to the image's palette set.
getPixelDepth
Returns the bits per pixel of the image.
getTransparentColor
Returns the transparent color (RGBQUAD) of the image, if transparent and >8 bits per pixel.
getTransparentIndex
Returns the transparent palette index of the image, if transparent and 8 bits per pixel.
getWidth
Returns the width in pixels of the image.
isPaletteColor
Returns TRUE if the image is 8 bits per pixel.
isTransparent
Returns TRUE if the image has source transparency.
replacePalette
Replaces a palette in the image's palette set with another.
serialize
Serializes the CK_Image object to disk.
setCompression
Installs a compression object to be used during serialization.
setOpaque
Clears the transparency info for the image.
setTransparentColor
Sets the transparent color for an image having greater than 8 bits per pixel.
setTransparentIndex
Sets the transparent palette index for an image having 8 bits per pixel.
usePaletteSet(CK_PaletteSet *palSet)
Associates a palette set with the image.
usePaletteSet(FILE *fp)
Deserializes a palette set and associates it with the image.

This factory method is used to create a CK_StaticImage from an already opened file. It can only be used with serialized objects, and not with pre-opened .pcx or .bmp files. The file pointer will be left at the beginning of the next object in the file.

Return Value
Returns a pointer to the image created. Return 0 if the file pointer did not point to a serialized CK_StaticImage.

Parameters

fp
File pointer pointing to the beginning of a serialized image. The file pointer should be from a file opened in binary mode - such as 'fopen("x.cim","rb")'.
com
The name of a compression object to be used for decompressing the image data. If null, no decompression will occur. The compression object must be the same as that used when serializing the image.

Creates a CK_StaticImage object from a .pcx, .bmp, or .cim file. Files ending in .pcx or .bmp are created with no transparency. If the graphics file is 8 bits per pixel, then the CK_StaticImage will contain a palette set with one palette. Files ending in .cim are serialized static images.

Return Value
Returns a pointer to the CK_StaticImage object created. If the file was missing, could not be opened, or did not contain the correct image file format, a null pointer is returned.

Parameters

fileName
The name of a .pcx, .bmp, or .cim file.
com
The name of a compression object to be used with .cim files for decompressing the image data. If null, no decompression will occur. The compression object must be the same as that used when serializing the image.

Creates a non-transparent CK_StaticImage object from a .bmp file. If the graphics file is 8 bits per pixel, then the CK_StaticImage will contain a palette set with one palette.

Return Value
Returns a pointer to the CK_StaticImage object created. A null pointer is returned if bitmap resource does not exist and the image could not be created.

Parameters

resourceID
The integer ID of the bitmap resource.