openmicroscopy/bioformats — pull request #1116 by rleigh-dundee (2014-05-19 21:25:05+00:00)
Title: cpp: Add TIFF support (1)

This PR adds initial support for TIFF reading; more will follow. The following classes are added:

- TIFF (open TIFF image)
- IFD (image file descriptor)
- Field (wrapper for an IFD+tag)
- Value and ValueProxy (wrap values to allow value retrieval from a Field; these are just for convenience)
- Tag enums
There are a few more lower-level classes such as Exception and Sentry and the Tag->type mapping.

The main aim of all the Field/Tag enum stuff is to make the library robust and catch any issues at compile time, i.e. make it easy to use while pushing the complexity into the wrappers. In contrast, libtiff is in someways simpler but pushes the burden of using it correctly onto the user, and crashing if they get it wrong. We won't allow an incorrect program to compile so it should be impossible for the user to call anything incorrectly; excluding any bugs on our part of libtiff changes, and even then should result in an exception rather than a crash.

This is all tested by the testcase added with the PR. At this point all baseline TIFF tags, plus some standard libtiff ones outside the baseline and imagej tags are supported. A number of additional non-baseline tags are not yet supported, but can easily be added if needed.

What is not in this PR:
- strip/tile load/store from pixel buffer
- IFD creation and TIFF writing
- TIFFReader
- showinf

Testing: the testcase should exercise all the tag reading and error handling paths, global libtiff recursive mutex, and all Field getter variants. It doesn't currently test tag writing though the code is present; this is waiting on TIFF write support. Probably most important at this point is a good review of the architecture of the wrappers; is there anything obviously wrong or confusing here?