| AWARE [SYSTEMS] | Imaging expertise for the Delphi developer | |||||||
![]() |
TIFF and LibTiff Mailing List Archive | |||||||
LibTiff Mailing List
TIFF and LibTiff Mailing List Archive Contact
The TIFF Mailing List Homepage |
Thread2010.12.06 23:27 "16 bit gray scale conversion", by Jamie L FinchDear Tiff Group,
I was assigned a bug in LightWaves bump mapping.
The complaint was that 16 bit tiffs do not show the same results as 32
bit tiffs.
I wanted to make sure that I am converting the tiffs to floating point
correctly.
I am most interested in 16 bit PHOTOMETRIC_MINISBLACK, which is the else
case. Can anyone confirm that the conversion from short to float is
correct ?
This conversion is before any color correction is applied.
Jamie Finch
NewTek, Inc.
/* Extract pixel values and send to LW... */
for( i = 0; i < Height; i++ ) {
TIFFReadScanline( tif, InBuf, i, 0 );
Sorc.SS = (short *) InBuf;
Dest.FP = (float *) IndexLine;
switch( BitsPerSample ) {
/* Grayscale. */
case 16:
if( Photometric == PHOTOMETRIC_MINISWHITE )
{ /* Gotta reverse values. */
for( j = 0; j < Width; j++ )
*Dest.FP++ = ( 65535.0F - (float)
*Sorc.US++ ) / 65535.0F;
}
else {
for( j = 0; j < Width; j++ )
*Dest.FP++ = ( (float) *Sorc.US++ )
/ 65535.0F;
}
break;
/* Grayscale. */
case 32:
if( Photometric == PHOTOMETRIC_MINISWHITE )
{ /* Gotta reverse values. */
for( j = 0; j < Width; j++ )
*Dest.FP++ = 1.0F - *Sorc.FP++;
}
else {
for( j = 0; j < Width; j++ )
*Dest.FP++ = *Sorc.FP++;
}
break;
}
if( LWIP_SENDLINE( ip, i, IndexLine ) != 0 )
break;
}
|
|||||||