FFTiffServices
single image TIFF file management

Prototype

Put the following prototype in the prototypes section of the application program header file:

int  ( __stdcall *pfnFFTiffServices )( int, HANDLE, void*, int, int );

Purpose

Create or read a single image TIFF file. The file must be compressed with the standard CCITT group IV-2d coding scheme.

Description and use

This function offers seven services numbered from 1 to 7. The first 5 services are useful for reading a file, the last 2 services are used to create a new file. The services are:
  • read file services:
    • service 1 - check TIFF signature
    • service 2 - get image width in pixels
    • service 3 - get image length in lines
    • service 4 - get the image comment (max 1024 bytes)
    • service 5 - position file pointer to the beginning of the compressed data
  • create file services:
    • service 6 - create and start writing a new TIFF file
    • service 7 - stop writing and close a new TIFF file
When reading a TIFF file the calling program is in charge for opening and closing the TIFF file using the standard Win32 APIs CreateFile and CloseHandle.

When reading a file, also, please call services 1, 2, 3, 4 and 5 in ascending sequence and don't miss any of them, differently an error could be returned.

An optional tag in the TIFF specification is used to record information about the image stored in the TIFF file. This tag is the ImageDescription tag. Since the beginning I had the idea to use this tag to record the database keys of the stored image.

For this reason I implemented the comment feature to read or write the database keys (or some other useful information) into the ImageDescription tag. You can write a comment (i.e. the database keys) using parameter 3 of service 6, and you can read the comment using the return value of service 4.

Using the image comment feature to store the image description (and/or the database keys) together with the images themselves is a very good way for developing robust applications.

Specification

This function is compliant with the TIFF specification rev. 6.0 - group B for black&white (bilevel) images. Tags used: NewSubfileType, ImageWidth, ImageLength, BitPerSample, Compression, PhotometricInterpretation, FillOrder, ImageDescription, StripsOffsets, SamplesPerPixel, RowsPerStrip, StripsByteCounts, XResolution, YResolution, T6Options, ResolutionUnit, Software, DateTime, NextIFD, HorzResolution, VertResolution. The image comment is stored in the ImageDescription tag.

Parameters

The meaning of the parameters varies according to the requested service:
  • first parameter: number of the requested service (from 1 to 7)
  • second parameter:
    • services 1, 4, 5, 7: TIFF file handle (you should open the file)
    • service 6: pointer to the ASCIIZ file name of the TIFF file to be created
    • services 2, 3: NULL
  • third parameter:
    • service 6: pointer to the ASCIIZ image comment string for the TIFF file to be created
    • services 1, 2, 3, 4, 5, 7: NULL
  • fourth parameter:
    • service 6: image width in pixels
    • services 1, 2, 3, 4, 5, 7: NULL
  • fifth parameter:
    • service 6: image length in lines
    • services 1, 2, 3, 4, 5, 7: NULL

Return value

The return value depends on the service that has been requested:
  • service 1: 0=the file is TIFF; 1=the file is not TIFF
  • service 2: image width in pixels
  • service 3: image length in lines
  • service 4: pointer to the ASCIIZ string with the image comment
  • service 5: 1=correctly positioned; anything else=error
  • service 6: handle to the newly created file (0=not created)
  • service 7: 1=correctly closed; anything else=error

Application examples

See also
  • FFDec: CCITT group 4 bidimensional decompression
  • FFView: 256 colours *full screen* bitmap display with pan, zoom, rotation, etc.
  • FFScan: SCSI scanner single page scan
  • FFComp: CCITT group 4 bidimensional compression

Notes