Blame contrib/win_dib/README.Tiffile

Packit Service 2594b8
Frank,
Packit Service 2594b8
Packit Service 2594b8
I attached a file that uses RGBA interface (tif_getimage.c) to read a tiff
Packit Service 2594b8
file and convert to a DIB.  It's advantage is that it is easy to read *any*
Packit Service 2594b8
tiff file suported by libtiff and easily convert it to a DIB.  The disadvantage
Packit Service 2594b8
is that bilevel (B&W) bitmaps (and all other non-rgba images) are also 
Packit Service 2594b8
converted to RGBA, thus taking up 32x as much memory as needed (4 bytes per 
Packit Service 2594b8
pixel, rather than 1 bit).  I read tiff files, but don't need to
Packit Service 2594b8
write them.  And my files are typically small, so the overhead is mostly
Packit Service 2594b8
inconsequential.  But for bilevel images, I overrode the get() and put()
Packit Service 2594b8
routines of the RGBA interface to just copy the data from the input raster
Packit Service 2594b8
to the output raster, rather than expanding out to full 32 bit format.  It
Packit Service 2594b8
would be nice if there were a simple way to handle all palletized images,
Packit Service 2594b8
but that would take more custom routines, and it's not that important to me.
Packit Service 2594b8
Packit Service 2594b8
Usage:
Packit Service 2594b8
Packit Service 2594b8
    m_pDIB = (PBITMAPINFOHEADER)::ReadTIFF(pathName);
Packit Service 2594b8
    if (m_pDIB != 0) {
Packit Service 2594b8
       m_format = IMAGETYPE_TIF;
Packit Service 2594b8
    }
Packit Service 2594b8
Packit Service 2594b8
This is intended as Win32, but the modifications for new get() and put()
Packit Service 2594b8
routines may be independent of platform.
Packit Service 2594b8
Packit Service 2594b8
Thanks for your work supporting the forum and the library!
Packit Service 2594b8
Packit Service 2594b8
Regards,
Packit Service 2594b8
Packit Service 2594b8
Mark James
Packit Service 2594b8
mark@james.net