2005.10.08 15:55 "[Tiff] Monochrome tiff to monochrome bitmap. Howto do it?", by

2005.10.08 17:27 "Re: [Tiff] Monochrome tiff to monochrome bitmap. Howto do it?", by Joris Van Damme

Frank,

Frank Mayer wrote:

Loading a monochrome tiff, it of course loads into the RGBA bitmap (using TIFFReadRGBAImage), thus using a lot more memory than necessary.

I would like to be able to specify my bitmap as monochrome and use pf1bit to load the monochrome tiff bitmap into it, so that I can keep the footprint of the program as little as possible,

But I have not found a way to read Monochrome tiff into monochrome bitmap. Am I missing something? Anyone has done this before?

You first need to see what color space and such is involved, unless by application logic you already know for sure that it's 1bit per pixel black and white.

Next, you need to detect whether strips or tiles are involved, and all such (on multi-channel colorspace, there is also the issue of planarconfiguration, subsampling, etc).

Next, depending on the outcome of the above, you can use the strip/tile access level of LibTiff. This yields exactly what is in the TIFF, i.e. for example 1 bit per pixel black and white, without converting to 32bit per pixel RGBA.

For the color space and storage detection, there's a number of tags you need to query. See http://www.remotesensing.org/libtiff/man/TIFFGetField.3tiff.html for a description of TIFFGetField, and http://www.awaresystems.be/imaging/tiff/tifftags.html for information on tags such as ImageWidth, ImageLength, BitsPerPixel, PhotometricInterpretation, PlanarConfiguration, etc.

For the strip/tile access level in LibTiff, see http://www.remotesensing.org/libtiff/libtiff.html for a very good introduction. And of course, bookmark the LibTiff man index page http://www.remotesensing.org/libtiff/man/index.html.

Joris Van Damme
info@awaresystems.be
http://www.awaresystems.be/
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html