Main Page   Modules   Alphabetical List   Data Structures   Data Fields  

RwImage
[Rasters, Textures & Images]


Data Structures

struct   RwImage

Typedefs

typedef RwImage *(*  RwImageCallBackRead )(const RwChar *imageName)
typedef RwImage *(*  RwImageCallBackWrite )(RwImage *image, const RwChar *imageName)

Functions

void  RwImageSetFreeListCreateParams (RwInt32 blockSize, RwInt32 numBlocksToPrealloc)
void  RwImageFormatSetFreeListCreateParams (RwInt32 blockSize, RwInt32 numBlocksToPrealloc)
RwImage RwImageCreate (RwInt32 width, RwInt32 height, RwInt32 depth)
RwBool  RwImageDestroy (RwImage *image)
RwImage RwImageSetStride (RwImage *image, RwInt32 stride)
RwImage RwImageSetPixels (RwImage *image, RwUInt8 *pixels)
RwImage RwImageSetPalette (RwImage *image, RwRGBA *palette)
RwInt32  RwImageGetWidth (const RwImage *image)
RwInt32  RwImageGetHeight (const RwImage *image)
RwInt32  RwImageGetDepth (const RwImage *image)
RwInt32  RwImageGetStride (const RwImage *image)
RwUInt8 RwImageGetPixels (const RwImage *image)
RwRGBA RwImageGetPalette (const RwImage *image)
RwImage RwImageAllocatePixels (RwImage *image)
RwImage RwImageFreePixels (RwImage *image)
RwImage RwImageResize (RwImage *image, RwInt32 width, RwInt32 height)
RwImage RwImageMakeMask (RwImage *image)
RwImage RwImageApplyMask (RwImage *image, const RwImage *mask)
const RwChar RwImageSetPath (const RwChar *path)
RwChar RwImageGetPath (void)
RwImage RwImageRead (const RwChar *imageName)
const RwChar RwImageFindFileType (const RwChar *imageName)
RwBool  RwImageRegisterImageFormat (const RwChar *extension, RwImageCallBackRead imageRead, RwImageCallBackWrite imageWrite)
RwImage RwImageWrite (RwImage *image, const RwChar *imageName)
RwImage RwImageReadMaskedImage (const RwChar *imageName, const RwChar *maskName)
RwImage RwImageCopy (RwImage *destImage, const RwImage *sourceImage)
RwInt32  RwImageRegisterPlugin (RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor constructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB)
RwInt32  RwImageGetPluginOffset (RwUInt32 pluginID)
RwBool  RwImageValidatePlugins (const RwImage *image)
RwInt32  RwImageStreamGetSize (const RwImage *image)
RwImage RwImageStreamRead (RwStream *stream)
const RwImage RwImageStreamWrite (const RwImage *image, RwStream *stream)
RwImage RwImageGammaCorrect (RwImage *image)
RwReal  RwImageGetGamma (void)
RwBool  RwImageSetGamma (RwReal gammaValue)
RwImage RwImageSetFromRaster (RwImage *image, RwRaster *raster)
RwImage RwImageFindRasterFormat (RwImage *ipImage, RwInt32 nRasterType, RwInt32 *npWidth, RwInt32 *npHeight, RwInt32 *npDepth, RwInt32 *npFormat)
RwImage RwImageResample (RwImage *dstImage, const RwImage *srcImage)
RwImage RwImageCreateResample (const RwImage *srcImage, RwInt32 width, RwInt32 height)

Detailed Description

Image handling.

RwImage Overview

Requirements

Overview

This object represents a platform-neutral bitmap.

Images are intended for loading and processing of bitmap data. They cannot be rendered directly by RenderWare Graphics and must be converted into raster ( RwRaster) objects prior to rendering.

The image object also supports file handling extensions that are completely separate from the RenderWare Binary Stream (see RwStream) system. This allows it to read and write known bitmap file formats, such as .BMP, .RAS and .PNG. By default, no such support is provided. You must link and register the appropriate Toolkits to support these extensions, or write your own.


Typedef Documentation

typedef RwImage*(* RwImageCallBackRead)(const RwChar * imageName)
 

RwImageCallBackRead is the function registered with RwImageRegisterImageFormat that is used, for example by RwImageRead and RwImageReadMaskedImage, to read images of a specific format from a disk file.

Parameters:
imageName  Pointer to a string containing the file name of the image.
Returns:
Returns a pointer to the image read.
See also:
RwImageRegisterImageFormat
typedef RwImage*(* RwImageCallBackWrite)(RwImage *image, const RwChar *imageName)
 

RwImageCallBackWrite is the function registered with RwImageRegisterImageFormat that is used, for example by RwImageWrite, to write images of a specific format to a disk file.

Parameters:
image  Pointer to the image.
imageName  Pointer to a string containing the file name of the image.
Returns:
Pointer to the written image.
See also:
RwImageRegisterImageFormat

Function Documentation

RwImage* RwImageAllocatePixels RwImage   image
 

RwImageAllocatePixels is used to allocate memory for pixels for the specified image. This function can be used following a call to RwImageCreate to allocate memory for a data array which will hold the pixel values of the image. If the image depth is 4 or 8-bits per pixel then memory is also allocated to hold the data for the image's palette.

Note that calling RwImageDestroy on the specified image will also free the memory allocated using this function. The pixel memory can also be freed using RwImageFreePixels, without destroying the image structure.

Parameters:
image  Pointer to the image to allocate pixels for.
Returns:
Returns pointer to the image if successful or NULL if there is an error.
See also:
RwImageFreePixels , RwImageSetPixels , RwImageSetPalette
RwImage* RwImageApplyMask RwImage   image,
const RwImage   mask
 

RwImageApplyMask applies an image's alpha mask to another image. Masking an image has the effect of copying the alpha channel (that part of the image controlling transparency) from the mask image to the destination image.

Both image and mask must have the same dimensions.

If the input image has 8 bits per pixel, the result of applying the mask is to convert the image to 32 bits per pixel, which allocates its own pixel array. Therefore, if the pixel data was previously registered using RwImageSetPixels, the original pixel data is not freed and should be destroyed by the application if necessary. This also means that the pointer returned by RwImageGetPixels will have changed after applying the mask.

Parameters:
image  Pointer to the image which will receive the mask
mask  Pointer to the image supplying the mask.
Returns:
Returns pointer to the image if successful or NULL if there is an error.
See also:
RwImageMakeMask , RwImageReadMaskedImage
RwImage* RwImageCopy RwImage   destImage,
const RwImage   sourceImage
 

RwImageCopy is used to copy the contents of one image to another. The source and destination images must have the same pixel resolution but they can have different depths. The only currently supported depth conversions are from 4 or 8- to 32-bits per pixels and it is an error to copy a 32-bit image to an 8 or 4-bit image. Note that the destination images must have memory allocated for its pixel data.

Parameters:
destImage  Pointer to the image receiving the image data
sourceImage  Pointer to the image supplying the image data.
Returns:
Returns a pointer to the destination image if successful or NULL if there is an error.
See also:
RwImageCreate
RwImage* RwImageCreate RwInt32    width,
RwInt32    height,
RwInt32    depth
 

RwImageCreate creates an image with the specified size and depth. Only images with depths 4, 8 and 32-bits per pixel are currently supported. For the former, pixel values are indices into a color look-up table or palette. For the latter, pixel values are true colors in red-green-blue-alpha format. Note that this function does not create space for the pixels or the palette, which can be allocated separately using RwImageAllocatePixels. However, API functions exist which can attach pre-existing pixel and palette data to the image, if required. If RwImageAllocatePixels has been used, then the image stride is automatically calculated, otherwise it must be explicitly determined and set.

Parameters:
width  An RwInt32 value equal to the width of the image
height  An RwInt32 value equal to the height of the image
depth  An RwInt32 value equal to the number of bits per pixel.
Returns:
Returns a pointer to the newly created image if successful or NULL if there is an error.
See also:
RwImageAllocatePixels , RwImageDestroy , RwImageSetPalette , RwImageSetPixels , RwImageSetStride
RwImage* RwImageCreateResample const RwImage   srcImage,
RwInt32    width,
RwInt32    height
 

RwImageCreateResample re-samples the specified image to a different size according to the width and height input arguments. This function creates a new image of the required size and with a depth of 32-bits per pixel, though the input image can have 8- or 32-bits per pixel. If the re-sampled image is smaller than the original, new pixels are calculated by averaging groups of pixels in the source image. If the re-sampling results in a larger image, pixel replication is used to determine new pixels in the output image. The source image is not altered in any way.

Parameters:
srcImage  A pointer to the image that will be re-sampled
width  An RwInt32 value equal to the width of the re-sampled image
height  An RwInt32 value equal to the height of the re-sampled image.
Returns:
Returns a pointer to the re-sampled image if successful or NULL if there is an error.
See also:
RwImageResample , RwImageCreate
RwBool RwImageDestroy RwImage   image
 

RwImageDestroy destroys the specified image. If the pixel and palette data arrays have been allocated using RwImageAllocatePixels this function frees the space allocated for them too.

Parameters:
image  Pointer to the image to destroy.
Returns:
Returns TRUE.
See also:
RwImageCreate
const RwChar* RwImageFindFileType const RwChar   imageName
 

RwImageFindFileType is used to search for an image of the specified name, conforming to one of the registered types. It returns an image extension identifying the type of image found, which when appended to the image name will permit loading of the image using RwImageRead or RwImageReadMaskedImage.

Parameters:
imageName  A pointer to a string containing the file name of the image without the extension.
Returns:
Returns a pointer to an extension, or NULL if no image could be found, or if the image filename already included an extension.
See also:
RwImageRead , RwImageReadMaskedImage , RwImageSetPath
Related Toolkits:

RtBMP, RtPNG, RtRAS and RtTIFF.

RwImage* RwImageFindRasterFormat RwImage   ipImage,
RwInt32    nRasterType,
RwInt32   npWidth,
RwInt32   npHeight,
RwInt32   npDepth,
RwInt32   npFormat
 

RwImageFindRasterFormat is used to determine a suitable raster format for a given image and the current target. Passing in the image to be considered, and a raster type flag containing type and mipmap format (not pixel format) will return a size, depth and format that can be used to create a suitable target raster for the image.

Parameters:
ipImage  A pointer to the image for which to determine a suitable raster format
nRasterType  A hint for the raster type and mipmap format to use
npWidth  A pointer to an RwInt32 value to receive the target raster's width
npHeight  A pointer to an RwInt32 value to receive the target raster's height
npDepth  A pointer to an RwInt32 value to receive the target raster's pixel depth
npFormat  A pointer to an RwInt32 value to receive the target raster's format.
Returns:
Returns a pointer to the image if successful, or NULL on failure.
See also:
RwRasterSetFromImage , RwRasterCreate , RwRasterGetFormat
void RwImageFormatSetFreeListCreateParams RwInt32    blockSize,
RwInt32    numBlocksToPrealloc
 

RwImageFormatSetFreeListCreateParams allows the developer to specify how many RwImage s to preallocate space for. Call before RwEngineInit.

Parameters:
blockSize  number of entries per freelist block.
numBlocksToPrealloc  number of blocks to allocate on RwFreeListCreateAndPreallocateSpace.
See also:
RwFreeList
RwImage* RwImageFreePixels RwImage   image
 

RwImageFreePixels is used to free memory previously allocated by RwImageAllocatePixels. This includes the pixel data and also the palette data array, where appropriate. It is an error to use this function if the pixel and palette data has been initialized using pre-existing data arrays via the functions RwImageSetPixels and RwImageSetPalette.

Parameters:
image  A pointer to the image whose pixel and palette data are to be destroyed.
Returns:
Returns a pointer to the image.
See also:
RwImageAllocatePixels , RwImageSetPixels , RwImageSetPalette.
RwImage* RwImageGammaCorrect RwImage   image
 

RwImageGammaCorrect is used to apply gamma correction to the specified image according to the currently set gamma correction value. The gamma value is specified using the function RwImageSetGamma.

Parameters:
image  Pointer to the image to gamma correct.
Returns:
Returns pointer to the image if successful or NULL if there is an error.
See also:
RwImageSetGamma , RwImageGetGamma
RwInt32 RwImageGetDepth const RwImage   image
 

RwImageGetDepth is used to determine the number of bits per pixel of the specified image. Currently, only images with 8- and 32-bits per pixels are supported.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

Parameters:
image  A pointer to the image whose depth is required.
Returns:
Returns an RwInt32 value equal to the image's depth in bits per pixel.
See also:
RwImageGetHeight , RwImageGetWidth , RwImageGetPalette , RwImageGetPixels , RwImageGetStride , RwImageGetWidth
RwReal RwImageGetGamma void   
 

RwImageGetGamma is used to retrieve the current gamma correction value.

Returns:
Returns an RwReal value equal to the gamma correction value currently in force.
See also:
RwImageSetGamma , RwImageGammaCorrect
RwInt32 RwImageGetHeight const RwImage   image
 

RwImageGetHeight is used to determine the height of the specified image in pixels.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

Parameters:
image  A pointer to the image whose height is required.
Returns:
Returns an RwInt32 value equal to the image's height.
See also:
RwImageGetDepth , RwImageGetWidth , RwImageGetPalette , RwImageGetPixels , RwImageGetStride
RwRGBA* RwImageGetPalette const RwImage   image
 

RwImageGetPalette is used to retrieve the specified image's palette data. This function is only relevant for images with 4 or 8-bits per pixel.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

Parameters:
image  A pointer to the image whose palette is required.
Returns:
Returns a pointer to the image's palette data array.
See also:
RwImageGetDepth , RwImageGetHeight , RwImageGetPixels , RwImageGetStride , RwImageGetWidth
RwChar* RwImageGetPath void   
 

RwImageGetPath is used in conjunction with image, raster and texture reading API functions, the search path is defined as the directory or directories in which the image files can be found. If more than one directory is specified, these must be separated using a semi-colon.

The search path can be considered to be either absolute or relative. In the latter case the search path is relative to the directory from which the application executable is running (the current directory). If no search path is specified (empty string) only the current directory is used.

Returns:
Returns pointer to a string describing the search path if successful or NULL if there is an error.
See also:
RwImageSetPath , RwImageRead , RwImageRegisterImageFormat , RwRasterRead , RwRasterReadMaskedRaster , RwTextureRead
RwUInt8* RwImageGetPixels const RwImage   image
 

RwImageGetPixels is used to retrieve the specified image's pixel data.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

Parameters:
image  A pointer to the image whose pixels are required.
Returns:
Returns a pointer to the image's pixel data array if successful or NULL if there is an error or if the image does not have any pixel data allocated.
See also:
RwImageGetDepth , RwImageGetHeight , RwImageGetPalette , RwImageGetStride , RwImageGetWidth
RwInt32 RwImageGetPluginOffset RwUInt32    pluginID
 

RwImageGetPluginOffset is used to get the offset of a previously registered plugin.

Parameters:
pluginID  The ID of the plugin whose data is to be retrieved.
Returns:
Returns an RwInt32 that equals the data block offset or -1 if the plugin is not registered.
See also:
RwImageRegisterPlugin , RwImageValidatePlugins
RwInt32 RwImageGetStride const RwImage   image
 

RwImageGetStride is used to determine the stride of the specified image. The stride is the number of bytes between the beginning of one scan-line of the image and the beginning of the next, taking account of padding such that each new scan-line falls on a 8-bit boundary.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

Parameters:
image  A pointer to the image whose stride is required.
Returns:
Returns an RwInt32 value equal to the image's stride.
See also:
RwImageGetWidth , RwImageGetHeight , RwImageGetDepth , RwImageGetPixels , RwImageGetPalette
RwInt32 RwImageGetWidth const RwImage   image
 

RwImageGetWidth is used to determine the width of the specified image in pixels.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

Parameters:
image  A pointer to the image whose width is required.
Returns:
Returns an RwInt32 value equal to the image's width.
See also:
RwImageGetDepth , RwImageGetHeight , RwImageGetPalette , RwImageGetPixels , RwImageGetStride
RwImage* RwImageMakeMask RwImage   image
 

RwImageMakeMask generates an alpha channel for the specified image based on it's pixel color values. The alpha channel is that part of the image controlling transparency and its value for each pixel is calculated here from the color channel values as follows: max(red, green, blue).

Parameters:
image  A pointer to the image whose alpha channel will be generated.
Returns:
Returns a pointer to the image.
See also:
RwImageApplyMask , RwImageReadMaskedImage
RwImage* RwImageRead const RwChar   imageName
 

RwImageRead is used to read an image from a disk file. The image file name can either be absolute or relative. In the latter case RwImageRead will use the current search path to determine in which directory the image file can be found. The format modules which have been registered using RwImageRegisterImageFormat, determine the types of files that are supported. Note that the filename must include the file's extension, as this identifies the images type for dispatch to the correct loader module.

No gamma correction is applied to the image.

Parameters:
imageName  A pointer to a string containing the file name of the image.
Returns:
Returns a pointer to the image if successful or NULL if there is an error.
See also:
RwImageWrite , RwImageRegisterImageFormat , RwImageSetPath , RwImageGammaCorrect , RwImageSetGamma , RwImageGetGamma , RwRasterRead , RwRasterReadMaskedRaster , RwTextureRead
RwImage* RwImageReadMaskedImage const RwChar   imageName,
const RwChar   maskName
 

RwImageReadMaskedImage is used to read an image from a disk file. Unlike RwImageRead this function also reads a second file that is used to create a transparency map in the first image. If the image file names are not absolute the current search path is used to determine in which directory the files can be found.

The format modules, which have been registered using RwImageRegisterImageFormat , determine the types of image files that are supported. Note that the filename must include the file's extension, as this identifies the image’s type for dispatch to the correct loader module.

No gamma correction is applied to the images.

Parameters:
imageName  A pointer to a string containing the file name of the first image
maskName  A pointer to a string containing the file name of the second image supplying the mask.
Returns:
Returns a pointer to the image with the new mask if successful or NULL if there is an error.
See also:
RwImageMakeMask , RwImageApplyMask , RwImageRead , RwImageRegisterImageFormat , RwImageSetPath , RwImageGammaCorrect , RwImageSetGamma , RwImageGetGamma , RwImageWrite , RwRasterRead , RwRasterReadMaskedRaster , RwTextureRead
RwBool RwImageRegisterImageFormat const RwChar   extension,
RwImageCallBackRead    imageRead,
RwImageCallBackWrite    imageWrite
 

RwImageRegisterImageFormat is used to register a new image format with RenderWare. This will allow loading and saving of the supplied image format if suitable callbacks are supplied.

RenderWare Graphics is supplied with a number of Toolkits containing such callbacks. These Toolkits can be used to add support for the following image formats:

  • Sun Microsystem's Raster, supported by the RtRAS Toolkit;
  • Portable Network Graphics, supported by the RtPNG Toolkit;
  • Microsoft Windows Bitmap, supported by the RtBMP Toolkit;
  • Tagged Image File Format, supported by the RtTIFF Toolkit;
See the Rasters, Images & Textures chapter in the User Guide for more in-depth coverage of this API.

These Toolkits replace the functionality found in previous releases. As a result, the following functions are now considered obsolete and will be deleted in a later release:

  • RwImageReadBMP()
  • RwImageReadRAS()
  • RwImageWriteBMP()
  • RwImageWriteRAS()
You can write your own image file format parsers by providing your own callback functions. The format of the read and write callbacks are:
   RwImage * (*RwImageCallBackRead)(const RwChar *imageName);
   RwImage *(*RwImageCallBackWrite)(RwImage *image, const RwChar *imageName);
  

An example of writing your own file format parser is provided in the ".../examples/imgformt/" folder.

Note that as a default there are no image formats registered with RenderWare. Also, image formats must be registered for reading textures and rasters from image files as these rely on the RwImage functionality.

This function must be used after the RenderWare engine has been started.

Sample Usage:

To enable reading and writing of Sun raster image files together with reading Windows Bitmap files, we must first make sure we are linking against the appropriate libraries, "rtras.lib" and "rtbmp.lib". Next, we include the header files, "rtras.h" and "rtbmp.h".

At this point, we can add the following lines to our code after the call to RwEngineOpen():

  
   RwImageRegisterImageFormat("ras", RtRASImageRead, RtRASImageWrite);
   RwImageRegisterImageFormat("bmp", RtBMPImageRead,NULL);
   
Parameters:
extension  Extension type for the image (e.g. bmp, ras)
imageRead  Pointer to a callback to allow reading of this image type (NULL for no reading possible)
imageWrite  Pointer to a callback to allow writing of this image type (NULL for no writing possible).
Returns:
Returns TRUE on success, or FALSE on failure.
See also:
RwImageRead , RwImageReadMaskedImage , RwImageWrite , RwImageSetPath
Related Toolkits: RtPNG, RtRAS, RtBMP, RtTIFF
RwInt32 RwImageRegisterPlugin RwInt32    size,
RwUInt32    pluginID,
RwPluginObjectConstructor    constructCB,
RwPluginObjectDestructor    destructCB,
RwPluginObjectCopy    copyCB
 

RwImageRegisterPlugin is used to register a plugin and reserve some space within a image. This must happen after the engine has been initialized but before the engine is opened.

Parameters:
size  An RwInt32 value equal to the size of the memory block to reserve
pluginID  An RwInt32 equal to the plugin's ID number
constructCB  A constructor for the plugin data block
destructCB  A destructor for the plugin data block
copyCB  A copy constructor for the plugin data block.
Returns:
Returns the byte offset within the image of memory reserved for this plugin or a negative value if there is an error.
See also:
RwImageValidatePlugins , RwImageGetPluginOffset
RwImage* RwImageResample RwImage   dstImage,
const RwImage   srcImage
 

RwImageResample re-samples the specified source image to a different size. The re-sampled size is that specified by the destination image which will receive the new image data. Both the source and destination images must be in 32-bit format. If the destination image is smaller than the source, new pixels in the destination are calculated by averaging groups of pixels in the source image. If the re-sampling results in a larger image, pixel replication is used to determine new pixels in the destination image. Note that the source and destination image pointers must not refer to the same image.

Parameters:
dstImage  A pointer to the destination image
srcImage  A pointer to the source image.
Returns:
Returns pointer to the destination image if successful or NULL if there is an error.
See also:
RwImageCreateResample , RwImageCreate , RwImageCopy
RwImage* RwImageResize RwImage   image,
RwInt32    width,
RwInt32    height
 

RwImageResize resizes the specified source image to a different size. If the image already has pixels allocated and the resized image is smaller than the original then pixel data will be clipped out as necessary. If pixels have already been allocated to the image and the resized image is larger than the original then the new pixels will return garbage. For example, if an image 275x120 is resized to 256x256 the image size is changed to 256x120 and the extra pixels are filled with garbage.

Parameters:
image  A pointer to the image to be resized
width  A resized width of the image
height  A resized height of the image.
Returns:
Returns a pointer to the resized image if successful or NULL if there is an error.
See also:
RwImageResample
void RwImageSetFreeListCreateParams RwInt32    blockSize,
RwInt32    numBlocksToPrealloc
 

RwImageSetFreeListCreateParams allows the developer to specify how many RwImage s to preallocate space for. Call before RwEngineInit.

Parameters:
blockSize  number of entries per freelist block.
numBlocksToPrealloc  number of blocks to allocate on RwFreeListCreateAndPreallocateSpace.
See also:
RwFreeList
RwImage* RwImageSetFromRaster RwImage   image,
RwRaster   raster
 

RwImageSetFromRaster is used to convert the specified (device dependent) raster into an equivalent (device independent) image. The image and raster dimensions should be the same and it is recommended that the image be created with a depth be 32-bits per pixel. The image must have pixels allocated for it before calling this function.

If the raster is locked before calling this function then the pixel data is taken from the currently locked mip level of the raster, and the lock is not released afterwards. Otherwise the raster is locked at mip level 0 in order to extract the pixel data and then unlocked afterwards.

Parameters:
image  A pointer to the image that will receive the raster data
raster  A pointer to the raster that supplies the image data.
Returns:
Returns pointer to the image if successful or NULL if there is an error.
   To grab and save the camera's image raster to a disk file: 
 
   RwRaster *raster;
   RwImage *image;
   RwInt32 x, y;
   RwChar *filename;
  
   raster = RwCameraGetRaster(camera);
   if( raster ) 
   {
       x = RwRasterGetWidth(raster);
       y = RwRasterGetHeight(raster);
       image = RwImageCreate(x, y, 32);
       if( image )
       {
           RwImageAllocatePixels(image);
           RwImageSetFromRaster(image, raster);
           RwImageWrite(image, filename);
           RwImageDestroy(image);
       }
   }
   
RwBool RwImageSetGamma RwReal    gammaValue
 

RwImageSetGamma is used to specify the current gamma correction value. Gamma values greater than 1.0 will lighten an image while values less than 1.0 will darken an image. Typically, used to adjust an image prior to display on a monitor whose gamma value differs from unity.

The default gamma value is ( RwReal)((1.0)).

Parameters:
gammaValue  An RwReal value equal to the gamma value to be set.
Returns:
Returns TRUE.
See also:
RwImageGetGamma , RwImageGammaCorrect
RwImage* RwImageSetPalette RwImage   image,
RwRGBA   palette
 

RwImageSetPalette is used to attach a pre-existing palette data array to the specified image. The palette data pointer references an array of allocated bytes large enough to accommodate all of the palette data (conforming with the image's depth). This function is typically used following a call to RwImageCreate to set the palette of an image when the palette data already exists in the required form.

This function should only be used for images which have 4 or 8-bits per pixel and have had their pixels allocated using RwImageSetPixels.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

Parameters:
image  A pointer to the image whose palette is to be set
palette  A pointer to the data array specifying the image's new palette.
Returns:
Returns pointer to the image.
See also:
RwImageCreate , RwImageGetPalette , RwImageSetPixels
const RwChar* RwImageSetPath const RwChar   path
 

RwImageSetPath is used to specify the current search path for reading images from the file system. Used in conjunction with image, raster and texture reading API functions, the search path is defined as the directory or directories in which the image files can be found. If more than one directory is specified, these must be separated using a semi-colon.

The search path can be considered to be either absolute or relative. In the latter case the search path is relative to the directory from which the application executable is running (the current directory). If no search path is specified (empty string) only the current directory is used.

Always include a trailing path separator in the directory name when setting the search path.

Parameters:
path  A pointer to a string describing the search path.
Returns:
Returns a pointer to the search path if successful or NULL if there is an error.
See also:
RwImageGetPath , RwImageRead , RwImageReadMaskedImage , RwRasterRead , RwRasterReadMaskedRaster , RwTextureRead
RwImage* RwImageSetPixels RwImage   image,
RwUInt8   pixels
 

RwImageSetPixels is used to attach a pre-existing pixel data array to the specified image. The pixel data pointer references an array of allocated bytes large enough to accommodate all of the image data (conforming with the image's width, height, depth and stride). This function is typically used following a call to RwImageCreate to set the pixels of an image when the image data already exists in the required form. The image stride should also be explicitly calculated and set at the same time. If the image data has 8 bits per pixel then a palette is also required, which can be attached to the image using RwImageSetPalette.

Note:
Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.
Note:
Note that calling RwImageDestroy on the specified image will not destroy the pixel data registered using RwImageSetPixels. It is the application's responsibility to do this, if required.
Parameters:
image  A pointer to the image whose pixel data is needed
pixels  A pointer to the data array specifying the image's pixel values.
Returns:
Returns pointer to the specified image.
See also:
RwImageAllocatePixels , RwImageCreate , RwImageGetPixels , RwImageSetPalette , RwImageSetStride
RwImage* RwImageSetStride RwImage   image,
RwInt32    stride
 

RwImageSetStride is used to specify the stride for the given image. The stride is the number of bytes between the beginning of one scan-line of the image and the beginning of the next, taking account of padding so that each new scan-line falls on an 8-bit boundary. For the currently supported image depths (8- and 32-bits per pixel) the stride is simply the image width multiplied by the number of bits per pixel. This function should be used if pixels are not set using RwImageAllocatePixels which automatically determines and sets the stride.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

Parameters:
image  A pointer to the image to set stride for
stride  An RwInt32 value equal to the image stride.
Returns:
Returns a pointer to the specified image.
See also:
RwImageGetStride , RwImageAllocatePixels , RwImageSetPixels , RwImageCreate
RwInt32 RwImageStreamGetSize const RwImage   image
 

RwImageStreamGetSize is used to determine the size in bytes of the binary representation of the given image.

This value is used in the binary chunk header to indicate the size of the chunk.

The size does not include the size of the chunk header.

Parameters:
image  A pointer to the image.
Returns:
Returns An RwInt32 value equal to the chunk size of the image in bytes.
See also:
RwImageStreamRead , RwImageStreamWrite
RwImage* RwImageStreamRead RwStream   stream
 

RwImageStreamRead is used to read an image from the specified binary stream.

Note that prior to this function call a binary image chunk must be found in the stream using the RwStreamFindChunk API function.

The sequence to locate and read an image from a binary stream connected to a disk file is as follows

   RwStream *stream;
   RwImage *newImage;
  
   stream = RwStreamOpen(rwSTREAMFILENAME, rwSTREAMREAD, "mybinary.xxx");
   if( stream )
   {
        if( RwStreamFindChunk(stream, rwID_IMAGE, NULL, NULL) )
        {
                newImage = RwImageStreamRead(stream);
        }
  
        RwStreamClose(stream, NULL);
  }
Parameters:
stream  A pointer to the stream.
Returns:
A pointer to the image if successful or NULL if there is an error.
See also:
RwImageStreamWrite , RwImageStreamGetSize , RwStreamOpen , RwStreamClose , RwStreamFindChunk
const RwImage* RwImageStreamWrite const RwImage   image,
RwStream   stream
 

RwImageStreamWrite is used to write the specified image to the given binary stream.

Note that the stream will have been opened prior to this function call.

Parameters:
image  A pointer to the image
stream  A pointer to the stream.
Returns:
Returns a pointer to the image if successful or NULL if there is an error.
See also:
RwImageStreamRead , RwImageStreamGetSize , RwStreamOpen , RwStreamClose
RwBool RwImageValidatePlugins const RwImage   image
 

RwImageValidatePlugins is used to validate the plugin memory allocated within the specified image. This function is useful for determining where memory trampling may be occurring within an application.

This function only returns a meaningful response under a debug library.

Parameters:
image  A pointer to the image to validate.
Returns:
Returns TRUE is the image data is valid or FALSE if there is an error or if the image data has become corrupt.
See also:
RwImageRegisterPlugin , RwImageGetPluginOffset
RwImage* RwImageWrite RwImage   image,
const RwChar   imageName
 

RwImageWrite is used to write an image to a disk file. The image file name must be absolute and include the extension. The extension determines the type of file written, and must correspond to one of the registered image formats (registered with RwImageRegisterImageFormat).

Note that if the image has been gamma corrected using RwImageGammaCorrect, the gamma correction is removed from the image before writing it to disk. Inverse gamma correction is performed using the current gamma correction value.

Parameters:
image  A pointer to the image
imageName  A pointer to a string containing the full path name of the image file.
Returns:
Returns a pointer to the image if successful or NULL if there is an error.
See also:
RwImageRead , RwImageRegisterImageFormat , RwImageReadMaskedImage , RwImageGammaCorrect , RwImageSetGamma , RwImageGetGamma
Related Toolkits:

RtBMP, RtPNG, RtRAS and RtTIFF.


Criterion Software © 1993-2003 Criterion Software Limited. All rights reserved. Built Tue Apr 22 12:46:14 2003. Send Feedback
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)