C Library

The C API is provided as a static or shared library. It requires no dependencies. We try to statically link wherever possible.

Open/Close

Use ScanImageTiffReader_Open() to open a file. When you’re done call ScanImageTiffReader_Close() to close any open file handles and cleanup any other resources in use.

Error handling

When errors occur, functions usually return a 0. Any error messages will be contained in the log field of the ScanImageTiffReader context object. Normally the log string is NULL; only after an error does it point to a null-terminated string.

Image data

To read the image data,

  1. Determine the size of the buffer you’ll need to hold the raw data using ScanImageTiffReader_GetDataSizeBytes().
  2. Allocate the memory you need.
  3. Read using ScanImageTiffReader_GetData(). This loads the entire volume into memory. There’s no option for reading just a subset of the data.

One nice thing about ScanImageTiffReader_GetData() is that many asynchronous read requests are made at once. This typically means that read commands will be coallesced and queued by the operating system so that very high read bandwidths can be acheived.

Metadata

Reading metadata follows a similar pattern. To read the frame-invariant metadata:

  1. Determine the size of the buffer you need using ScanImageTiffReader_GetMetadataSizeBytes().
  2. Read it using ScanImageTiffReader_GetMetadata().

The frame-varying metadata is read using a similar pattern. There are two sets of functions for reading the frame varying data: