/************************************************************************ TIFF support is optional. Only PNM support is guaranteed to be available. Since it is optional, the TIFF code is contained here in a separate source file. Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. $Id: MxRaster-tiff.cxx,v 1.5 1999/01/22 17:26:12 garland Exp $ ************************************************************************/ #include "stdmix.h" #include "MxRaster.h" #ifdef MIX_HAVE_LIBTIFF #include //////////////////////////////////////////////////////////////////////// // // TIFF output // static bool __tiff_write(TIFF *tif, const MxRaster& img) { TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, img.width()); TIFFSetField(tif, TIFFTAG_IMAGELENGTH, img.height()); TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, img.channels()); TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8); TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); // Turn on LZW compression. Shhhhh! Don't tell Unisys! TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_LZW); // // Predictors: // 1 (default) -- No predictor // 2 -- Horizontal differencing TIFFSetField(tif, TIFFTAG_PREDICTOR, 2); uint32 scanline_size = img.channels() * img.width(); if( TIFFScanlineSize(tif) != scanline_size ) { mxmsg_signal(MXMSG_WARN, "Mismatch with library's expected scanline size!", "tiff_write"); return false; } TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(tif, -1)); char *scanline_buf = new char[scanline_size]; const unsigned char *scanline = img; for(uint32 y=0; y