/************************************************************************/ /* */ /* Copyright 1998-2002 by Ullrich Koethe */ /* Cognitive Systems Group, University of Hamburg, Germany */ /* */ /* This file is part of the VIGRA computer vision library. */ /* The VIGRA Website is */ /* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */ /* Please direct questions, bug reports, and contributions to */ /* koethe@informatik.uni-hamburg.de or */ /* vigra@kogs1.informatik.uni-hamburg.de */ /* */ /* Permission is hereby granted, free of charge, to any person */ /* obtaining a copy of this software and associated documentation */ /* files (the "Software"), to deal in the Software without */ /* restriction, including without limitation the rights to use, */ /* copy, modify, merge, publish, distribute, sublicense, and/or */ /* sell copies of the Software, and to permit persons to whom the */ /* Software is furnished to do so, subject to the following */ /* conditions: */ /* */ /* The above copyright notice and this permission notice shall be */ /* included in all copies or substantial portions of the */ /* Software. */ /* */ /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */ /* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */ /* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */ /* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */ /* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */ /* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */ /* OTHER DEALINGS IN THE SOFTWARE. */ /* */ /************************************************************************/ #ifndef VIGRA_TIFF_HXX #define VIGRA_TIFF_HXX #include "vigra/utilities.hxx" #include "vigra/numerictraits.hxx" #include "vigra/rgbvalue.hxx" extern "C" { #include #include } namespace vigra { typedef TIFF TiffImage; /** \defgroup TIFFImpex Import/export of the TIFF format TIFF conversion and file export/import. Normally, you need not call the TIFF functions directly. They are available much more conveniently via \ref importImage() and \ref exportImage() TIFF (Tagged Image File Format) is a very versatile image format - one can store different pixel types (byte, integer, float, double) and color models (black and white, RGB, mapped RGB, other color systems). For more details and information on how to create a TIFF image, refer to the TIFF documentation at http://www.libtiff.org/ for details. */ //@{ /********************************************************/ /* */ /* importTiffImage */ /* */ /********************************************************/ /** \brief Convert given TiffImage into image specified by iterator range. Accessors are used to write the data. This function calls \ref tiffToScalarImage() or \ref tiffToRGBImage(), depending on the accessor's value_type. Declarations: pass arguments explicitly: \code namespace vigra { template void importTiffImage(TiffImage * tiff, ImageIterator iter, Accessor a) } \endcode use argument objects in conjunction with \ref ArgumentObjectFactories: \code namespace vigra { template void importTiffImage(TiffImage * tiff, pair dest) } \endcode Usage: \#include "vigra/tiff.hxx" \code uint32 w, h; TiffImage * tiff = TIFFOpen("tiffimage.tiff", "r"); TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &h); vigra::BImage img(w,h); vigra::importTiffImage(tiff, destImage(img)); TIFFClose(tiff); \endcode Required Interface: see \ref tiffToScalarImage() and \ref tiffToRGBImage() Preconditions: see \ref tiffToScalarImage() and \ref tiffToRGBImage() */ template inline void importTiffImage(TiffImage * tiff, ImageIterator iter, Accessor a) { typedef typename NumericTraits::isScalar isScalar; importTiffImage(tiff, iter, a, isScalar()); } template inline void importTiffImage(TiffImage * tiff, pair dest) { importTiffImage(tiff, dest.first, dest.second); } template inline void importTiffImage(TiffImage * tiff, ImageIterator iter, Accessor a, VigraTrueType) { tiffToScalarImage(tiff, iter, a); } template inline void importTiffImage(TiffImage * tiff, ImageIterator iter, Accessor a, VigraFalseType) { tiffToRGBImage(tiff, iter, a); } /********************************************************/ /* */ /* tiffToScalarImage */ /* */ /********************************************************/ /** \brief Convert single-band TiffImage to scalar image. This function uses accessors to write the data. Declarations: pass arguments explicitly: \code namespace vigra { template void tiffToScalarImage(TiffImage * tiff, ImageIterator iter, Accessor a) } \endcode use argument objects in conjunction with \ref ArgumentObjectFactories: \code namespace vigra { template void tiffToScalarImage(TiffImage * tiff, pair dest) } \endcode Usage: \#include "vigra/tiff.hxx" \code uint32 w, h; uint16 photometric TiffImage * tiff = TIFFOpen("tiffimage.tiff", "r"); TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &h); TIFFGetField(tiff_, TIFFTAG_PHOTOMETRIC, &photometric); if(photometric != PHOTOMETRIC_MINISWHITE && photometric != PHOTOMETRIC_MINISBLACK) { // not a scalar image - handle error } vigra::BImage img(w,h); vigra::tiffToScalarImage(tiff, destImage(img)); TIFFClose(tiff); \endcode Required Interface: \code ImageIterator upperleft; value; Accessor accessor; accessor.set(value, upperleft); \endcode Preconditions: ImageIterator must refer to a large enough image. \code uint16 sampleFormat, samplesPerPixel, bitsPerSample, photometric; TIFFGetField(tiff, TIFFTAG_SAMPLEFORMAT, &sampleFormat); TIFFGetField(tiff, TIFFTAG_SAMPLESPERPIXEL, &samplesPerPixel); TIFFGetField(tiff, TIFFTAG_BITSPERSAMPLE, &bitsPerSample); TIFFGetField(tiff, TIFFTAG_PHOTOMETRIC, &photometric); sampleFormat != SAMPLEFORMAT_VOID samplesPerPixel == 1 photometric == PHOTOMETRIC_MINISWHITE || photometric == PHOTOMETRIC_MINISBLACK bitsPerSample == 1 || bitsPerSample == 8 || bitsPerSample == 16 || bitsPerSample == 32 || bitsPerSample == 64 \endcode */ template void tiffToScalarImage(TiffImage * tiff, ImageIterator iter, Accessor a) { vigra_precondition(tiff != 0, "tiffToScalarImage(TiffImage *, ScalarImageIterator): " "NULL pointer to input data."); uint16 sampleFormat = 1, bitsPerSample, fillorder, samplesPerPixel, photometric; uint32 w,h; TIFFGetField(tiff, TIFFTAG_SAMPLEFORMAT, &sampleFormat); TIFFGetField(tiff, TIFFTAG_BITSPERSAMPLE, &bitsPerSample); TIFFGetField(tiff, TIFFTAG_SAMPLESPERPIXEL, &samplesPerPixel); TIFFGetField(tiff, TIFFTAG_FILLORDER, &fillorder); TIFFGetField(tiff, TIFFTAG_PHOTOMETRIC, &photometric); TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &h); vigra_precondition(photometric == PHOTOMETRIC_MINISWHITE || photometric == PHOTOMETRIC_MINISBLACK, "tiffToScalarImage(TiffImage *, ScalarImageIterator): " "Image isn't grayscale."); vigra_precondition(samplesPerPixel == 1, "tiffToScalarImage(TiffImage *, ScalarImageIterator): " "Image is multiband, not scalar."); vigra_precondition(sampleFormat != SAMPLEFORMAT_VOID, "tiffToScalarImage(TiffImage *, ScalarImageIterator): " "undefined pixeltype (SAMPLEFORMAT_VOID)."); ImageIterator yd(iter); int bufsize = TIFFScanlineSize(tiff); tdata_t * buf = new tdata_t[bufsize]; int offset, scale, max, min; if(photometric == PHOTOMETRIC_MINISWHITE) { min = 255; max = 0; scale = -1; offset = 255; } else { scale = 1; offset = 0; min = 0; max = 255; } try{ switch(sampleFormat) { case SAMPLEFORMAT_UINT: { switch (bitsPerSample) { case 1: { for(unsigned int y=0; y> (7 - x%8)) & 1) ? max : min, xd); } else { a.set(((((uint8 *)buf)[x/8] >> (x%8)) & 1) ? max : min, xd); } } } break; } case 8: { for(unsigned int y=0; y> (7 - x%8)) & 1) ? max : min, xd); } else { a.set(((((int8 *)buf)[x/8] >> (x%8)) & 1) ? max : min, xd); } } } break; } case 8: { for(unsigned int y=0; y void tiffToScalarImage(TiffImage * tiff, pair dest) { tiffToScalarImage(tiff, dest.first, dest.second); } /********************************************************/ /* */ /* tiffToRGBImage */ /* */ /********************************************************/ /** \brief Convert RGB (3-band or color-mapped) TiffImage to RGB image. This function uses \ref RGBAccessor to write the data. A RGBImageIterator is an iterator which is associated with a RGBAccessor. Declarations: pass arguments explicitly: \code namespace vigra { template void tiffToRGBImage(TiffImage * tiff, RGBImageIterator iter, RGBAccessor a) } \endcode use argument objects in conjunction with \ref ArgumentObjectFactories: \code namespace vigra { template void tiffToRGBImage(TiffImage * tiff, pair dest) } \endcode Usage: \#include "vigra/tiff.hxx" \code uint32 w, h; uint16 photometric TiffImage * tiff = TIFFOpen("tiffimage.tiff", "r"); TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &h); TIFFGetField(tiff_, TIFFTAG_PHOTOMETRIC, &photometric); if(photometric != PHOTOMETRIC_RGB && photometric != PHOTOMETRIC_PALETTE) { // not an RGB image - handle error } vigra::BRGBImage img(w, h); vigra::tiffToRGBImage(tiff, destImage(img)); TIFFClose(tiff); \endcode Required Interface: \code ImageIterator upperleft; rvalue, gvalue, bvalue; RGBAccessor accessor; accessor.setRed(rvalue, upperleft); accessor.setGreen(gvalue, upperleft); accessor.setBlue(bvalue, upperleft); \endcode Preconditions: ImageIterator must refer to a large enough image. \code uint16 sampleFormat, samplesPerPixel, bitsPerSample, photometric; TIFFGetField(tiff, TIFFTAG_SAMPLEFORMAT, &sampleFormat); TIFFGetField(tiff, TIFFTAG_SAMPLESPERPIXEL, &samplesPerPixel); TIFFGetField(tiff, TIFFTAG_BITSPERSAMPLE, &bitsPerSample); TIFFGetField(tiff, TIFFTAG_PHOTOMETRIC, &photometric); sampleFormat != SAMPLEFORMAT_VOID samplesPerPixel == 3 // unlass photometric == PHOTOMETRIC_PALETTE photometric == PHOTOMETRIC_RGB || photometric == PHOTOMETRIC_PALETTE bitsPerSample == 1 || bitsPerSample == 8 || bitsPerSample == 16 || bitsPerSample == 32 || bitsPerSample == 64 \endcode */ template void tiffToRGBImage(TiffImage * tiff, RGBImageIterator iter, RGBAccessor a) { vigra_precondition(tiff != 0, "tiffToRGBImage(TiffImage *, RGBImageIterator): " "NULL pointer to input data."); uint16 sampleFormat = 1, bitsPerSample, samplesPerPixel, planarConfig, photometric; uint32 w,h; TIFFGetField(tiff, TIFFTAG_SAMPLEFORMAT, &sampleFormat); TIFFGetField(tiff, TIFFTAG_BITSPERSAMPLE, &bitsPerSample); TIFFGetField(tiff, TIFFTAG_SAMPLESPERPIXEL, &samplesPerPixel); TIFFGetField(tiff, TIFFTAG_PHOTOMETRIC, &photometric); TIFFGetField(tiff, TIFFTAG_PLANARCONFIG, &planarConfig); TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &h); vigra_precondition(photometric == PHOTOMETRIC_RGB || photometric == PHOTOMETRIC_PALETTE, "tiffToRGBImage(TiffImage *, RGBImageIterator): " "Image isn't RGB."); vigra_precondition(sampleFormat != SAMPLEFORMAT_VOID, "tiffToRGBImage(TiffImage *, RGBImageIterator): " "undefined pixeltype (SAMPLEFORMAT_VOID)."); RGBImageIterator yd(iter); switch (photometric) { case PHOTOMETRIC_PALETTE: { uint32 * raster = new uint32[w*h]; try { if (!TIFFReadRGBAImage(tiff, w, h, raster, 0)) { vigra_fail( "tiffToRGBImage(TiffImage *, RGBImageIterator): " "unable to read image data."); } for(unsigned int y=0; y void tiffToRGBImage(TiffImage * tiff, pair dest) { tiffToRGBImage(tiff, dest.first, dest.second); } template struct CreateTiffImage; /********************************************************/ /* */ /* createTiffImage */ /* */ /********************************************************/ /** \brief Create a TiffImage from the given iterator range. Type and size of the TiffImage are determined by the input image. Currently, the function can create scalar images and RGB images of type unsigned char, short, int, float, and double. This function uses accessors to read the data. Declarations: pass arguments explicitly: \code namespace vigra { template inline TiffImage * createTiffImage(ImageIterator upperleft, ImageIterator lowerright, Accessor a) } \endcode use argument objects in conjunction with \ref ArgumentObjectFactories: \code namespace vigra { template inline TiffImage * createTiffImage(triple src) } \endcode Usage: \#include "vigra/tiff.hxx" \code vigra::BImage img(width, height); ... TiffImage * tiff = TIFFOpen(("tiffimage.tiff", "w"); vigra::createTiffImage(srcImageRange(img), tiff); TIFFClose(tiff); // implicitly writes the image to the disk \endcode Required Interface: \code ImageIterator upperleft; Accessor accessor; accessor(upperleft); // result written into TiffImage \endcode */ template inline void createTiffImage(ImageIterator upperleft, ImageIterator lowerright, Accessor a, TiffImage * tiff) { CreateTiffImage:: exec(upperleft, lowerright, a, tiff); } template inline void createTiffImage(triple src, TiffImage * tiff) { createTiffImage(src.first, src.second, src.third, tiff); } /********************************************************/ /* */ /* createScalarTiffImage */ /* */ /********************************************************/ /** \brief Create a single-band TiffImage from the given scalar image. Type and size of the TiffImage are determined by the input image (may be one of unsigned char, short, int, float, or double). This function uses accessors to read the data. Declarations: pass arguments explicitly: \code namespace vigra { template inline TiffImage * createScalarTiffImage(ImageIterator upperleft, ImageIterator lowerright, Accessor a) } \endcode use argument objects in conjunction with \ref ArgumentObjectFactories: \code namespace vigra { template inline TiffImage * createScalarTiffImage(triple src) } \endcode Usage: \#include "vigra/tiff.hxx" \code vigra::BImage img(width, height); ... TiffImage * tiff = TIFFOpen(("tiffimage.tiff", "w"); vigra::createScalarTiffImage(srcImageRange(img), tiff); TIFFClose(tiff); // implicitly writes the image to the disk \endcode Required Interface: \code ImageIterator upperleft; Accessor accessor; accessor(upperleft); // result written into TiffImage \endcode */ template inline void createScalarTiffImage(ImageIterator upperleft, ImageIterator lowerright, Accessor a, TiffImage * tiff) { CreateTiffImage:: exec(upperleft, lowerright, a, tiff); } template inline void createScalarTiffImage(triple src, TiffImage * tiff) { createScalarTiffImage(src.first, src.second, src.third, tiff); } template void createBScalarTiffImage(ImageIterator upperleft, ImageIterator lowerright, Accessor a, TiffImage * tiff) { int w = lowerright.x - upperleft.x; int h = lowerright.y - upperleft.y; TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, w); TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, h); TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8); TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 1); TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tiff, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); int bufsize = TIFFScanlineSize(tiff); tdata_t * buf = new tdata_t[bufsize]; ImageIterator ys(upperleft); try { for(int y=0; y void createShortScalarTiffImage(ImageIterator upperleft, ImageIterator lowerright, Accessor a, TiffImage * tiff) { int w = lowerright.x - upperleft.x; int h = lowerright.y - upperleft.y; TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, w); TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, h); TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 16); TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 1); TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tiff, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_INT); TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); int bufsize = TIFFScanlineSize(tiff); tdata_t * buf = new tdata_t[bufsize]; ImageIterator ys(upperleft); try { for(int y=0; y void createIScalarTiffImage(ImageIterator upperleft, ImageIterator lowerright, Accessor a, TiffImage * tiff) { int w = lowerright.x - upperleft.x; int h = lowerright.y - upperleft.y; TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, w); TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, h); TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 32); TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 1); TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tiff, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_INT); TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); int bufsize = TIFFScanlineSize(tiff); tdata_t * buf = new tdata_t[bufsize]; ImageIterator ys(upperleft); try { for(int y=0; y void createFScalarTiffImage(ImageIterator upperleft, ImageIterator lowerright, Accessor a, TiffImage * tiff) { int w = lowerright.x - upperleft.x; int h = lowerright.y - upperleft.y; TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, w); TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, h); TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, sizeof(float)*8); TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 1); TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tiff, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP); TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); int bufsize = TIFFScanlineSize(tiff); tdata_t * buf = new tdata_t[bufsize]; ImageIterator ys(upperleft); try { for(int y=0; y void createDScalarTiffImage(ImageIterator upperleft, ImageIterator lowerright, Accessor a, TiffImage * tiff) { int w = lowerright.x - upperleft.x; int h = lowerright.y - upperleft.y; TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, w); TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, h); TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, sizeof(double)*8); TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 1); TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tiff, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP); TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); int bufsize = TIFFScanlineSize(tiff); tdata_t * buf = new tdata_t[bufsize]; ImageIterator ys(upperleft); try { for(int y=0; y struct CreateTiffImage { template static void exec(ImageIterator upperleft, ImageIterator lowerright, Accessor a, TiffImage * tiff) { createBScalarTiffImage(upperleft, lowerright, a, tiff); } }; template <> struct CreateTiffImage { template static void exec(ImageIterator upperleft, ImageIterator lowerright, Accessor a, TiffImage * tiff) { createShortScalarTiffImage(upperleft, lowerright, a, tiff); } }; template <> struct CreateTiffImage { template static void exec(ImageIterator upperleft, ImageIterator lowerright, Accessor a, TiffImage * tiff) { createIScalarTiffImage(upperleft, lowerright, a, tiff); } }; template <> struct CreateTiffImage { template static void exec(ImageIterator upperleft, ImageIterator lowerright, Accessor a, TiffImage * tiff) { createFScalarTiffImage(upperleft, lowerright, a, tiff); } }; template <> struct CreateTiffImage { template static void exec(ImageIterator upperleft, ImageIterator lowerright, Accessor a, TiffImage * tiff) { createDScalarTiffImage(upperleft, lowerright, a, tiff); } }; /********************************************************/ /* */ /* createRGBTiffImage */ /* */ /********************************************************/ /** \brief Create a 3-band TiffImage from the given RGB image. Type and size of the TiffImage are determined by the input image (may be one of unsigned char, int, float, or double). This function uses \ref RGBAccessor to read the data. A RGBImageIterator is an iterator that is associated with a RGBAccessor. Declarations: pass arguments explicitly: \code namespace vigra { template TiffImage * createRGBTiffImage(RGBImageIterator upperleft, RGBImageIterator lowerright, RGBAccessor a) } \endcode use argument objects in conjunction with \ref ArgumentObjectFactories: \code namespace vigra { template inline TiffImage * createRGBTiffImage(triple src) } \endcode Usage: \#include "vigra/tiff.hxx" \code vigra::BRGBImage img(width, height); ... TiffImage * tiff = TIFFOpen(("tiffimage.tiff", "w"); vigra::createRGBTiffImage(srcImageRange(img), tiff); TIFFClose(tiff); // implicitly writes the image to the disk \endcode Required Interface: \code ImageIterator upperleft; RGBAccessor accessor; accessor.red(upperleft); // result written into TiffImage accessor.green(upperleft); // result written into TiffImage accessor.blue(upperleft); // result written into TiffImage \endcode */ template inline void createRGBTiffImage(RGBImageIterator upperleft, RGBImageIterator lowerright, RGBAccessor a, TiffImage * tiff) { CreateTiffImage:: exec(upperleft, lowerright, a, tiff); } template inline void createRGBTiffImage(triple src, TiffImage * tiff) { createRGBTiffImage(src.first, src.second, src.third, tiff); } template void createBRGBTiffImage(RGBImageIterator upperleft, RGBImageIterator lowerright, RGBAccessor a, TiffImage * tiff) { int w = lowerright.x - upperleft.x; int h = lowerright.y - upperleft.y; TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, w); TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, h); TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8); TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 3); TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tiff, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); int bufsize = TIFFScanlineSize(tiff); tdata_t * buf = new tdata_t[bufsize]; RGBImageIterator ys(upperleft); try { for(int y=0; y void createShortRGBTiffImage(RGBImageIterator upperleft, RGBImageIterator lowerright, RGBAccessor a, TiffImage * tiff) { int w = lowerright.x - upperleft.x; int h = lowerright.y - upperleft.y; TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, w); TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, h); TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 16); TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 3); TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tiff, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_INT); TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); int bufsize = TIFFScanlineSize(tiff); tdata_t * buf = new tdata_t[bufsize]; RGBImageIterator ys(upperleft); try { for(int y=0; y void createIRGBTiffImage(RGBImageIterator upperleft, RGBImageIterator lowerright, RGBAccessor a, TiffImage * tiff) { int w = lowerright.x - upperleft.x; int h = lowerright.y - upperleft.y; TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, w); TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, h); TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 32); TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 3); TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tiff, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_INT); TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); int bufsize = TIFFScanlineSize(tiff); tdata_t * buf = new tdata_t[bufsize]; RGBImageIterator ys(upperleft); try { for(int y=0; y void createFRGBTiffImage(RGBImageIterator upperleft, RGBImageIterator lowerright, RGBAccessor a, TiffImage * tiff) { int w = lowerright.x - upperleft.x; int h = lowerright.y - upperleft.y; TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, w); TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, h); TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, sizeof(float)*8); TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 3); TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tiff, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP); TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); int bufsize = TIFFScanlineSize(tiff); tdata_t * buf = new tdata_t[bufsize]; RGBImageIterator ys(upperleft); try { for(int y=0; y void createDRGBTiffImage(RGBImageIterator upperleft, RGBImageIterator lowerright, RGBAccessor a, TiffImage * tiff) { int w = lowerright.x - upperleft.x; int h = lowerright.y - upperleft.y; TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, w); TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, h); TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, sizeof(double)*8); TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 3); TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tiff, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP); TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); int bufsize = TIFFScanlineSize(tiff); tdata_t * buf = new tdata_t[bufsize]; RGBImageIterator ys(upperleft); try { for(int y=0; y struct CreateTiffImage > { template static void exec(ImageIterator upperleft, ImageIterator lowerright, Accessor a, TiffImage * tiff) { createBRGBTiffImage(upperleft, lowerright, a, tiff); } }; template <> struct CreateTiffImage > { template static void exec(ImageIterator upperleft, ImageIterator lowerright, Accessor a, TiffImage * tiff) { createShortRGBTiffImage(upperleft, lowerright, a, tiff); } }; template <> struct CreateTiffImage > { template static void exec(ImageIterator upperleft, ImageIterator lowerright, Accessor a, TiffImage * tiff) { createIRGBTiffImage(upperleft, lowerright, a, tiff); } }; template <> struct CreateTiffImage > { template static void exec(ImageIterator upperleft, ImageIterator lowerright, Accessor a, TiffImage * tiff) { createFRGBTiffImage(upperleft, lowerright, a, tiff); } }; template <> struct CreateTiffImage > { template static void exec(ImageIterator upperleft, ImageIterator lowerright, Accessor a, TiffImage * tiff) { createDRGBTiffImage(upperleft, lowerright, a, tiff); } }; //@} } // namespace vigra #endif /* VIGRA_TIFF_HXX */