clCompressImage(3dm) clCompressImage(3dm)
clCompressImage, clDecompressImage - Compress/Decompress a single image
#include <dmedia/cl.h>
int clCompressImage(int scheme, int width, int height,
int format, float compressionRatio, void *frameBuffer,
int *compressedBufferSizePtr, void *compressedBuffer)
int clDecompressImage(int scheme, int width, int height,
int format, int compressedBufferSize,
void *compressedBuffer, void *frameBuffer)
scheme The compression/decompression scheme to use.
width The width of the image.
height The height of the image.
format The format of the original image to (de)compress :
CL_FORMAT_BGR, CL_FORMAT_XBGR, CL_FORMAT_ABGR,
CL_FORMAT_BGR332, CL_FORMAT_GRAYSCALE, CL_FORMAT_YCbCr,
CL_FORMAT_YCbCr422, or CL_FORMAT_YCbCr422DC.
compressionRatio
The target compression ratio. The actual compression ratio
depends on this value and the particular codec. A value of 0.0
indicates the default should be used.
frameBuffer
A pointer to the frame buffer.
compressedBufferSizePtr
A pointer to the size of the compressed data buffer in bytes.
The value pointed to is overwritten by clCompressImage to
return the actual size of the compressed data.
compressedBufferSize
The size of the compressed data in bytes.
compressedBuffer
A pointer to the compressed data buffer.
clCompressImage compresses the image in frameBuffer and stores the result
in compressedBuffer and the resulting size in compressedBufferSizePtr.
clDecompressImage decompresses the data in compressedBuffer of size
compressedBufferSize and stores the resulting image in frameBuffer.
The values of the state parameters used with the other compression
Page 1
clCompressImage(3dm) clCompressImage(3dm)
library calls have no effect on these routines, however their default
values do. width, height, format, and compressionRatio are interpreted in
the same manner as the corresponding state parameters, but are given as
direct parameters so that they may be specified in the same call.
Each function returns SUCCESS, or a negative error code on failure.
/* Compress and decompress a 320 by 240 XBGR image with JPEG */
int frameIndex, compressedBufferSize, maxCompressedBufferSize;
int *compressedBuffer, frameBuffer[320][240];
/* malloc a big enough buffer */
maxCompressedBufferSize = 320 * 240 * CL_BytesPerPixel(CL_FORMAT_XBGR)
+ clQueryMaxHeaderSize(CL_JPEG_SOFTWARE);
compressedBuffer = (int *)malloc(maxCompressedBufferSize);
/* Compress and decompress it */
clCompressImage(CL_JPEG_SOFTWARE, 320, 240, CL_FORMAT_XBGR, 15.0,
frameBuffer, &compressedBufferSize, compressedBuffer);
clDecompressImage(CL_JPEG_SOFTWARE, 320, 240, CL_FORMAT_XBGR,
compressedBufferSize, compressedBuffer, frameBuffer);
CLintro(3dm)
PPPPaaaaggggeeee 2222 [ Back ]
|