Data Structures | |
| struct | RwPalQuant |
Functions | |
| void | RwPalQuantSetMaxDepth (RwUInt32 depth) |
| RwUInt32 | RwPalQuantGetMaxDepth (void) |
| void | RwPalQuantAddImage (RwPalQuant *pq, RwImage *img, RwReal weight) |
| RwInt32 | RwPalQuantResolvePalette (RwRGBA *palette, RwInt32 maxcols, RwPalQuant *pq) |
| void | RwPalQuantMatchImage (RwUInt8 *dstpixels, RwInt32 dststride, RwInt32 dstdepth, RwBool dstPacked, RwPalQuant *pq, RwImage *img) |
| RwBool | RwPalQuantInit (RwPalQuant *pq) |
| void | RwPalQuantTerm (RwPalQuant *pq) |
This functionality is used internally in certain image to raster conversion processes (e.g. RwTextureRasterGenerateMipmaps).
The quantization process involves initializing an RwPalQuant object, accumulating pixel data for a series of images, resolving a palette, then generating the new palettized image data.
The following code shows an example of generating a 4-bit palettized image (destImage) from a given source image (sourceImage).
RwImage *destImage; RwPalQuant pq; destImage = RwImageCreate( RwImageGetWidth(sourceImage), RwImageGetHeight(sourceImage), 4); RwImageAllocatePixels(destImage); RwPalQuantInit(&pq); RwPalQuantAddImage(&pq, sourceImage, 1.0f); RwPalQuantResolvePalette(RwImageGetPalette(destImage), 16, &pq); RwPalQuantMatchImage(RwImageGetPixels(destImage), RwImageGetStride(destImage), RwImageGetDepth(destImage), FALSE, &pq, sourceImage); RwPalQuantTerm(&pq);
The RwPalQuant structure contains a color quantization tree. This has a maximum depth given by RwPalQuantSetMaxDepth, which can be anything up to 8 (for 32-bit RGBA color depth). The highest values require significantly more memory and processing time. If this value is modified it should be done before calling RwPalQuantInit. The current value may be queried using RwPalQuantGetMaxDepth.
|
||||||||||||||||
|
RwPalQuantAddImage adds each pixel in the image to the quantization tree population.
weight value can be used to adjust the contribution of the higher levels.
|
|
|
RwPalQuantGetMaxDepth returns the maximum depth of the tree used for palette quantization.
|
|
|
RwPalQuantInit initializes a palette quantization tree structure. This will use the current maximum tree depth set by RwPalQuantSetMaxDepth. This should not be modified while the RwPalQuant structure is in use.
|
|
||||||||||||||||||||||||||||
|
RwPalQuantMatchImage matches an image to the given quantization tree, and writes new palette index image data. This should be called after using RwPalQuantResolvePalette.
|
|
||||||||||||||||
|
RwPalQuantResolvePalette uses the quantization tree in an RwPalQuant object to find a set of representative colors and store them in the specified palette.
|
|
|
RwPalQuantSetMaxDepth sets the maximum depth of the tree used for palette quantization. The deeper the tree, the more memory and time will be used by the quantization process, but the better the results, particularly on images with subtle color gradients. This function should be used before initializing an RwPalQuant object.
|
|
|
RwPalQuantTerm deinitializes a palette quantization tree structure
|
© 1993-2004 Criterion Software Limited. All rights reserved. Built Thu Feb 12 13:46:53 2004.
Send Feedback