Status: Read
Received: from [192.48.153.1] by phillip.thumbsplus.com (NTMail 3.03.0013/7.aaxh) with ESMTP id pcrews for <pcrews@cerious.com>; Wed, 18 Feb 1998 06:31:47 -0400
Received: from cthulhu.engr.sgi.com (cthulhu.engr.sgi.com [192.26.80.2]) by sgi.sgi.com (950413.SGI.8.6.12/970507) via ESMTP id DAA23973; Wed, 18 Feb 1998 03:17:54 -0800
	env-from (owner-tiff@sgi.engr.sgi.com)
Received: (from majordomo-owner@localhost) by cthulhu.engr.sgi.com (950413.SGI.8.6.12/960327.SGI.AUTOCF) id CAA23077 for tiff-list; Wed, 18 Feb 1998 02:33:17 -0800
Received: from sgi.sgi.com (sgi.engr.sgi.com [192.26.80.37]) by cthulhu.engr.sgi.com (950413.SGI.8.6.12/960327.SGI.AUTOCF) via ESMTP id CAA23060 for <tiff-relay@cthulhu.engr.sgi.com>; Wed, 18 Feb 1998 02:33:15 -0800
Received: from web1.clubnet.net (web1.clubnet.net [206.126.128.3]) by sgi.sgi.com (950413.SGI.8.6.12/970507) via ESMTP id CAA12505
	for <tiff@sgi.com>; Wed, 18 Feb 1998 02:33:14 -0800
	env-from (rnw@earthlink.net)
Received: from dualpentium (39.powerproduction.com [157.22.201.39])
	by web1.clubnet.net (8.8.6/8.8.6) with SMTP id CAA18243
	for <tiff@sgi.com>; Wed, 18 Feb 1998 02:33:13 -0800 (PST)
X-Authentication-Warning: web1.clubnet.net: Host 39.powerproduction.com [157.22.201.39] claimed to be dualpentium
Reply-To: "Raymond Walsh" <rnw@earthlink.net>
From: "Raymond Walsh" <rnw@earthlink.net>
To: <tiff@sgi.com>
Subject: tiff lib question / bug (?)
Date: Wed, 18 Feb 1998 02:25:57 -0800
Message-ID: <01bd3c57$9a014e00$27c9169d@dualpentium.tangentrc.com>
MIME-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 4.71.1712.3
X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3
Sender: owner-tiff@fddi-sgi.sgi.com
Precedence: bulk

Hello



Heres my setup:
Version 3.4
OS: Win NT ( 4.0 servicepak 3 in case you're interested )
Compiler: VC++ 5.0
Target: Win32 ( debug )

I created the *.lib by using the *.mak file I found in the \contrib\WinNT
folder.
I know thats not a supported version, but the Windows specific aspect doesnt
seem to be my trouble... Please read on :)




i'm dabbling with this wonderful tiff library.
I have TIFFs created in Photoshop 4.0 Macintosh, saved as PC & Mac tiffs
with and without LZW ( all 4 cases )


I open the tiff,
tif = TIFFOpen( (*path), "ru" ); //read, un-memory mapped ( the
memory-mapped version crashes my machine but thats another story )

...get the height & width...
TIFFGetField( tif, TIFFTAG_IMAGEWIDTH, &w );
TIFFGetField( tif, TIFFTAG_IMAGELENGTH, &h );

....get my memory buffer....
...

....and read the bits....
TIFFReadRGBAImage( tif, w, h, raster, 0 );


...and close the file




TIFFReadRGBAImage has the alpha channel as all 0xff.
Every darn pixel!
I know for a fact that there are other alpha values in there.... so i step
into code. :)

I follow it down into:
pickTileContigCase(TIFFRGBAImage* img)
...
switch (img->photometric)
...
case PHOTOMETRIC_RGB:
switch (img->bitspersample)
{
case 8:
//ok so I have a 8 bit per sample, RGB, photometric TIFF...
if (!img->Map)    //map == 0, and my ->alpha == 0, so i get the "ignore
alpha" "put" routine... but wait darn it, the Alpha shouldnt be 0
    {
     if (img->alpha == EXTRASAMPLE_ASSOCALPHA)
     put = putRGBAAcontig8bittile;
     else if (img->alpha == EXTRASAMPLE_UNASSALPHA)
     put = putRGBUAcontig8bittile;
     else
     put = putRGBcontig8bittile;    <--------------------------- im getting
this one, but I want one of the other 2...
    }



//so if I add a line ( or two ) to:
"int TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char
emsg[1024])"...I can make the image appear the way I want it to.

in "TIFFRGBAImageBegin" ( tif_getimage.c )
theres one "switch" right away. then the following code:

    img->alpha = 0;
    TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL,
&img->samplesperpixel);
    TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES,&extrasamples,
&sampleinfo);
    if (extrasamples == 1)
{    //i've added a bracket here cuz of the line(s) i'm adding
   switch (sampleinfo[0])
  {
  case EXTRASAMPLE_ASSOCALPHA: /* data is pre-multiplied */
  case EXTRASAMPLE_UNASSALPHA: /* data is not pre-multiplied */
   img->alpha = sampleinfo[0];
   break;
  }
.........................AFTER THAT CODE I'M
ADDING..............................................
 //if the alpha is still empty, but there are 4 channels, then one of those
channels is the alpha, damnit
 //so we're gunna make it one of the 2 types of alphachannels
 //photoshop4.0 Macintosh seems to make sampleinfo[0] == 0
  if( img->alpha == 0 )
   {
   if( img->samplesperpixel == 4 )
   {
   //this is arbitrary, take your pick...
   // EXTRASAMPLE_UNASSALPHA | EXTRASAMPLE_ASSOCALPHA
    img->alpha = EXTRASAMPLE_UNASSALPHA ;
   }
  }
 }



Am I messing up your awesome library?
or have I found some obscure alphachannel related quirk?
or does photoshop generate substandard TIFF images?
Or am I an idiot who should just learn to live with it? :)

Did you get all that? If you want or need more information I can probably
explain that in more detail.

thanks for your attention
ray

