#include "BITIFF.H"
TIFFFILE CALLBACK OpenTiffInMemory( HANDLE hHndl,
DWORD dwSize,
int iMode)
Description
Opens a TIFF file stored in memory 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 TIFF file stored in memory. 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. This function is useful for network applications to avoid file I/O.
Parameters
HANDLE |
hHndl |
A memory block handle that contains the TIFF file data to be opened. This handle must be returned by the GlobalAlloc() Win32 API function. The memory block can be movable or fixed. |
DWORD |
dwSize |
The size of the memory block. |
int |
iMode |
Create (T_CREATE), append (T_APPEND) or read (T_READ). |
Return values
A handle to an inner structure containing detailed information on the TIFF image chain or NULL if an error occurred. You can use this handle in as many functions as you can use the one returned by OpenTiffFile().
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 OpenTiffFile(), GetMemoryTiffHandle() and CloseTiffFile().
Code example
#include "BITIFF.H"
TIFFILE hTiffFile;
HANDLE hTiff;
DWORD dwSize;
.
.
hTiff = GlobalAlloc(GHND, dwSize);
.
.
// Fill up the memory block with TIFF data.
.
.
// The memory block is dwSize bytes long.
hTiffFile = OpenTiffInMemory(hTiff, dwSize, 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.
}
GlobalFree(hTiff);
...