OpenTiffFile

#include "BITIFF.H"

TIFFFILE CALLBACK OpenTiffFile(LPTSTR lpszFileName, int iMode)

Description

Opens the specified TIFF file and builds an image chain structure for encoding or decoding. If iMode is equal to T_READ or T_APPEND, the function fills this structure with the basic information retrieved from the specified TIFF file. If iMode is equal to T_CREATE, then a new chain is created and the byte order is set to LH_BYTE_ORDER. It can be modified by calling ModiTiffFileInfo(). The returned handle must be saved, because most of the functions manipulating TIFF images require this handle to identify the image chain.

Parameters

LPTSTR

lpszFileName

Name of TIFF file to open.

int

iMode

Create (T_CREATE), append (T_APPEND) or read (T_READ).

Additional Information

This example shows how to use the dll when loading statically including the header file. Otherwise if the dll is loaded dynamically, for further information read the “About the difference of static and dynamic library loading” section of the manual.

Return values

A handle to an inner structure containing detailed information on the TIFF image chain or NULL if an error occurred.

Programming notes

The returned handle refers to the image chain. Use GetTiffImage() to register a specific image in the chain. It is your responsibility to free the inner structure of the TIFF image chain by calling CloseTiffFile(). Beware, after doing this, the image chain handle becomes invalid.

Requirements

Header :     Declared in BiTiff.h; include BiTiff.h.

Library :    Use BiTIFF.lib.

DLLs :       BiTiff.dll.

References to related functions

See CloseTiffFile(), GetTiffFileInfo() and ModiTiffFileInfo().

Code example

#include "BITIFF.H"

TIFFILE hTiffFile;

.

.

.

hTiffFile = OpenTiffFile((LPSTR)"c:\\tiff\\test.tif",T_READ);

if(hTiffFile == NULL)

{ // Error occurred.

                switch(TiffError()

                {

                                case TFILEIOERROR:       // I/O error.

                                                ...

                                case TNOTTIFFILE:           // Not TIFF file format.

                                                ...

                                case TNOTENOUGHMEMORY:  // Not enough memory.

                                                ...

                                default:                  // Other error.

                                                ...

                }

}

else

{ // File opening OK.

                if (GetTiffImage(hTiffFile,0))           // Gets first TIFF image in the TIFF file.

                {

                                .

                                .

                                .

                                DropTiffImage(hTiffFile,0);             // Drops the image.

                }

                CloseTiffFile(hTiffFile);     // Frees related structures.

}

...