<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2654.45">
<TITLE>a possible fix for vtkTIFFReader?</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2 FACE="Arial">Hi guys!</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Since I started working with VTK, I've always had problems reading TIFFs. Though true-color TIFFs would display just fine, rendering colormapped TIFFs would always result in a blank canvas of nothingness. </FONT></P>
<P><FONT SIZE=2 FACE="Arial">After mucking around in the code for the vtkTIFFReader, I found that I wasn't getting null pixel values; The class read the data good enough, however the resulting values weren't in the correct range (0-255).</FONT></P>
<P><FONT SIZE=2 FACE="Arial">I changed the following lines of code in vtkTIFFReader::EvaluateImageAt().</FONT>
</P>
<P><FONT SIZE=2 FACE="Courier">case vtkTIFFReader::PALETTE_RGB:</FONT>
<BR><FONT SIZE=2 FACE="Courier"> this->GetColor(*source, &red, &green, &blue); </FONT>
<BR><FONT SIZE=2 FACE="Courier"> *(image) = static_cast<unsigned char>(red<B> >> 8</B>);</FONT>
<BR><FONT SIZE=2 FACE="Courier"> *(image+1) = static_cast<unsigned char>(green</FONT><B> <FONT SIZE=2 FACE="Courier">>> 8</FONT></B><FONT SIZE=2 FACE="Courier">);</FONT>
<BR><FONT SIZE=2 FACE="Courier"> *(image+2) = static_cast<unsigned char>(blue</FONT><B> <FONT SIZE=2 FACE="Courier">>> 8</FONT></B><FONT SIZE=2 FACE="Courier">);</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">and, to my jaw-dropping astonishment, the pixels values fell in the correct range and my 8-bit TIFF image displayed correctly!</FONT></P>
<P><FONT SIZE=2 FACE="Arial">So, what exactly is going on here? Are the images I work with buggered up, or has this always been a problem with the vtkTIFFReader?</FONT></P>
<P><FONT SIZE=2 FACE="Arial">Any comments? </FONT>
<BR><FONT SIZE=2 FACE="Arial">--</FONT>
<BR><FONT SIZE=2 FACE="Arial">Maik Flanagin</FONT>
<BR><FONT SIZE=2 FACE="Arial">Contractor</FONT>
<BR><FONT SIZE=2 FACE="Arial">ACS </FONT>
<BR><FONT SIZE=2 FACE="Arial">U.S. Army Corps of Engineers - New Orleans District</FONT>
</P>
</BODY>
</HTML>