ilInitFile(3X)
NAME
ilInitFile() − initialize a file as a null TIFF file
SYNOPSIS
ilBool
ilInitFile (
ilContext context,
FILE *stream,
long offset,
ilBool MSBIsFirst,
unsigned long mustBeZero);
DESCRIPTION
ilInitFile() writes a TIFF header to the given stream, creating a null TIFF file and deleting any images that are already in the file. It is generally used after the file has been created by calling fopen(3S), using the access mode (type) w+. The stream must then be closed by calling fclose(), then reopened with mode r or r+ before calling ilConnectFile() and ilWriteFileImage() to write images to the file.
TIFF as well as other types of image files can also be written using EFS function calls; see ilEFSOpen(3X).
context identifies a context created by IL_CREATE_CONTEXT().
*stream identifies the stream used to access the TIFF file; returned by fopen(3S).
offset identifies the byte offset where the TIFF header should be written; use zero (0) for TIFF files. offset is non-zero only if a TIFF file is contained within another file at byte location offset.
MSBIsFirst if TRUE, sets the byte order of the file to Motorola byte order (recommended); if FALSE, sets it to Intel byte order. Both byte orders are supported by the Image Library and by standard TIFF readers.
mustBeZero identifies a value that must be zero; this parameter is reserved for future use.
RETURN VALUE
Upon successful completion, ilInitFile() returns TRUE.
ERRORS
If the call fails, context->error receives a non-zero error code.
EXAMPLE
The following example creates a null file, opens it for output, and connects the IL to it, for writing a TIFF file.
char filename[];
ilContext context;
FILE stdioFile;
ilFile pFile;
.
.
.
stdioFile = fopen(filename, "w+");
if (stdioFile) { /∗ first create il context ∗/
if (!ilInitFile (context, stdioFile, 0, TRUE, 0))
return(context->error);
fclose (stdioFile);
stdioFile = fopen(filename, "r+");
if (!(pFile = ilConnectFile (context, stdioFile, 0, 0)))
return(context->error);
}
AUTHOR
ilInitFile() was developed by HP.
SEE ALSO
ilConnectFile(3X), fopen(3S), ftell(3S).
Using the Image Developer’s Kit.
Hewlett-Packard Company — Image Library: February, 1995