POV-Ray : Newsgroups : povray.beta-test : Suspicious PGM/PPM file format handling : Re: Suspicious PGM/PPM file format handling Server Time
6 Jul 2024 06:49:29 EDT (-0400)
  Re: Suspicious PGM/PPM file format handling  
From: clipka
Date: 14 Sep 2009 10:46:31
Message: <4aae5747$1@news.povray.org>
Ive schrieb:
> There are indeed some (but very rare) PNM files that seem to assume 
> "maxvalue" is the maximal value that *appears* within the image out of 
> the full range of 0-65535 but this is a bug within the used PNM-writer 
> and shouldn't become our problem.

Good.

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.


Post a reply to this message

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