From 360e7629d06094d3509ac6ecc1e05a71ecc9781d Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 11 Jul 2008 19:43:01 +0000 Subject: [PATCH] From Christophe Loustaunau, "For our application, we need to write tiff file in floats. I have change a little bit the readerWritterTiff : It check the data type of the image ( img.getDataType() ) and if it's GL_FLOAT :It save the tiff with float values. Otherwise it does the same thing as before." --- src/osgPlugins/tiff/ReaderWriterTIFF.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/osgPlugins/tiff/ReaderWriterTIFF.cpp b/src/osgPlugins/tiff/ReaderWriterTIFF.cpp index 295f6c2b9..b6372ab75 100644 --- a/src/osgPlugins/tiff/ReaderWriterTIFF.cpp +++ b/src/osgPlugins/tiff/ReaderWriterTIFF.cpp @@ -689,6 +689,7 @@ class ReaderWriterTIFF : public osgDB::ReaderWriter TIFF *image; int samplesPerPixel; + int bitsPerSample; uint16 photometric; image = TIFFClientOpen("outputstream", "w", (thandle_t)&fout, @@ -728,9 +729,20 @@ class ReaderWriterTIFF : public osgDB::ReaderWriter break; } + switch(img.getDataType()){ + case GL_FLOAT: + TIFFSetField(image, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP); + TIFFSetField(image, TIFFTAG_ROWSPERSTRIP, 1); + bitsPerSample = 32; + break; + default: + bitsPerSample = 8; + break; + } + TIFFSetField(image, TIFFTAG_IMAGEWIDTH,img.s()); TIFFSetField(image, TIFFTAG_IMAGELENGTH,img.t()); - TIFFSetField(image, TIFFTAG_BITSPERSAMPLE,8); + TIFFSetField(image, TIFFTAG_BITSPERSAMPLE,bitsPerSample); TIFFSetField(image, TIFFTAG_SAMPLESPERPIXEL,samplesPerPixel); TIFFSetField(image, TIFFTAG_PHOTOMETRIC, photometric); TIFFSetField(image, TIFFTAG_COMPRESSION, COMPRESSION_PACKBITS);