Return-Path: <tiff-bounces@lists.maptools.org>
X-Original-To: info@awaresystems.be
Delivered-To: info@awaresystems.be
Received: from mx-q.b-one.net (mx-q.one.com [91.198.169.248])
	by mail9.b-one.net (Postfix) with ESMTP id E77EF40014C
	for <info@awaresystems.be>; Tue,  7 Dec 2010 00:33:14 +0100 (CET)
Received: by mx-q.b-one.net (Postfix, from userid 106)
	id DE576144C0E5; Tue,  7 Dec 2010 00:32:32 +0100 (CET)
X-Virus-Scanned: by one.com
X-Spam-Flag: NO
X-Spam-Score: 0
X-Spam-Level: 
X-Spam-Status: No, score=0 tagged_above=0 required=4 tests=[none]
X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4
Received: from lists.maptools.org (lists.maptools.org [65.39.174.144]) by
 mx-q.b-one.net (Postfix) with ESMTP id 70F28144C0EA for
 <info@awaresystems.be>; Tue,  7 Dec 2010 00:32:31 +0100 (CET)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by
 lists.maptools.org (Postfix) with ESMTP id C64AA1CFEF3E0; Mon,  6 Dec 2010
 18:31:10 -0500 (EST)
Received: from mail.newtek.com (falcon-vm.newtek.com [199.79.203.7]) by
 lists.maptools.org (Postfix) with ESMTP id BD69B1CFEF3E0 for
 <tiff@lists.maptools.org>; Mon,  6 Dec 2010 18:27:59 -0500 (EST)
Received: (qmail 25716 invoked from network); 6 Dec 2010 17:27:36 -0600
Received: from dell-i7.ops.newtek.com (HELO ?10.28.18.232?)
 (jfinch@10.28.18.232) by mail.newtek.com with SMTP; 6 Dec 2010 17:27:36 -0600
Message-ID: <4CFD7178.2090708@cruzio.com>
Date: Mon, 06 Dec 2010 17:27:52 -0600
From: "Jamie L. Finch" <wi6f@cruzio.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.12)
 Gecko/20101027 Thunderbird/3.1.6
MIME-Version: 1.0
To: tiff@lists.maptools.org
Subject: [Tiff] 16 bit gray scale conversion
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: TIFF and libtiff discussion <tiff.lists.maptools.org>
List-Unsubscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
 <mailto:tiff-request@lists.maptools.org?subject=unsubscribe>
List-Archive: <http://lists.maptools.org/mailman/private/tiff>
List-Post: <mailto:tiff@lists.maptools.org>
List-Help: <mailto:tiff-request@lists.maptools.org?subject=help>
List-Subscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
 <mailto:tiff-request@lists.maptools.org?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org

Dear 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;
                     }

_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
