Decoding images

Two functions are supplied to decode TIFF images:

BOOL CALLBACK DecodeTiffImage(TIFFFILE hChain, int nImage, WORD wFirstStrip,
WORD wNumLines, LONG lParam, FILLPROC lpLineFn);

BOOL CALLBACK DecodeCcittImage(int nFile, WORD wWidth, WORD wHeight,
DWORD dwCompression, LONG lParam, FILLPROC lpLineFn);

Function Descriptions

DecodeTiffImage() decodes a TIFF image. Call OpenTiffFile() and GetTiffImage() to retrieve an image chain handle and to register an image before you call this function.

DecodeCcittImage() decodes any type of CCITT raw image. The file must be opened via any handle-oriented functions such as _lopen(). Position the file pointer at the first code bytes in the image file. You must know the wWidth, wHeight and dwCompression parameters to decode the image. After decoding, the file can be closed by any handle-oriented file closing function such as _lclose().

A user-defined callback function must be passed to both functions. This function will receive the decompressed lines of the image line-by-line in a device-independent bitmap (DIB) form. Using a callback function for this purpose provides the possibility of advised bitmap handling (e.g., direct image transport to clipboard, DDE pipe, or another file from TIFF). This avoids the necessity of keeping the whole (and possibly huge) image in your application’s memory.

The callback function pointed by the lpLineFn parameter must use the Pascal calling convention and must have the following form:

int CALLBACK LineFn(LPSTR lpLineBuff, int nLine, LONG lParam)

LineFn is a placeholder for the application-supplied function name. You can use any other name for this purpose.

Below is a brief definition of parameters:

LPSTR lpLineBuff     Buffer containing a single line uncompressed DIB (of course, without header).

int nLine                      Index of the line. Line numbers are started from zero.

LONG lParam             Same as the lParam parameter that you passed to the DecodeTiffImage orDecodeCcittImage function.

Function returns consist of: 1) Error status, and 2) TOK if OK.

Examples Of Decoding

The following examples are to demonstrate various methods available to decode a TIFF image. Some of the code fragments are parts of your sample application distributed with this software package and they may change without notice.