POV-Ray : Newsgroups : povray.beta-test : Suspicious PGM/PPM file format handling : Re: Suspicious PGM/PPM file format handling Server Time
6 Jul 2024 05:36:05 EDT (-0400)
  Re: Suspicious PGM/PPM file format handling  
From: Ive
Date: 14 Sep 2009 11:40:26
Message: <4aae63ea$1@news.povray.org>
clipka wrote:

> Another thing: In the various file readers, I frequently encounter the 
> following construct:
> 
>   floatColor = ((intColor * 255) / intMax) / 255.0;
> 
> where intMax is derived from the bit depth of the color component.
> Does this make any sense to you? Wouldn't it be more faithful to the 
> encoded data to decode it as
> 
>   floatColor = float(intColor) / float(intMax) ?
> 
> My initial assumption was that it's just lazy coding, with the /255.0 
> having been added when refactoring the code to use float values, but the 
> frequent appearance makes me uneasy.


Assuming floatColor was once a byteColor it really looks like a relict 
of the once used MulDiv approach. I cannot see a reason for keeping that.


Ahem, and in case you came across tiff.cpp, could you please change the line

if (PhotometricInterpretation == PHOTOMETRIC_PALETTE)

to

if ((PhotometricInterpretation == PHOTOMETRIC_PALETTE) && 
(TIFFIsTiled(tif) == 0))


This will prevent POV-Ray from having a few pointers running wild when 
someone tries to use a color palette TIF-file that happens to be tiled 
and is not arranged in strips.

-Ive


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.