From 8dd9c542291f7cbf4fc5421b2a71d006e0ff8c28 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 18 Sep 2008 12:50:20 +0000 Subject: [PATCH] From Robert Osfield and Christophe Loustaunau, fixes for support for 16bit and 32bit tiff images --- src/osgPlugins/tiff/ReaderWriterTIFF.cpp | 139 +++++++++++++++++------ 1 file changed, 103 insertions(+), 36 deletions(-) diff --git a/src/osgPlugins/tiff/ReaderWriterTIFF.cpp b/src/osgPlugins/tiff/ReaderWriterTIFF.cpp index 9153b35e0..b3ed735a7 100644 --- a/src/osgPlugins/tiff/ReaderWriterTIFF.cpp +++ b/src/osgPlugins/tiff/ReaderWriterTIFF.cpp @@ -260,7 +260,6 @@ checkcmap(int n, uint16* r, uint16* g, uint16* b) return (8); } - static void invert_row(unsigned char *ptr, unsigned char *data, int n, int invert, uint16 bitspersample) { @@ -273,7 +272,7 @@ invert_row(unsigned char *ptr, unsigned char *data, int n, int invert, uint16 bi else *ptr++ = *data++; } } - else + else if (bitspersample == 16) { unsigned short *ptr1 = (unsigned short *)ptr; unsigned short *data1 = (unsigned short *)data; @@ -284,6 +283,17 @@ invert_row(unsigned char *ptr, unsigned char *data, int n, int invert, uint16 bi else *ptr1++ = *data1++; } } + else if (bitspersample == 32) + { + float *ptr1 = (float *)ptr; + float *data1 = (float *)data; + + while (n--) + { + if (invert) *ptr1++ = 1.0 - *data1++; + else *ptr1++ = *data1++; + } + } } @@ -302,46 +312,99 @@ unsigned short *rmap, unsigned short *gmap, unsigned short *bmap) } } - -static void -copy_row(unsigned char *ptr, unsigned char *data, int n, int numSamples) -{ - // osg::notify(osg::NOTICE)<<"Copy row"<setImage(s,t,r,