|
|
I have come across some suspicious code in:
App: POV-Ray for Windows 3.6
Module: source/targa.cpp
Func: convert_targa_color
Line: ~807
The code converts two physical pixel bytes into an IMAGE_COLOUR.
However, in the 16-bit case the physical-to-logical conversion leaves
the bottom three bits of each logical 8-bit RGB channel to zero, doing a
slightly incorrect scaling of the color data from 5 bits to 8 bits. 100%
white, for example, winds up 97% white.
The code
tcolor->Red = ((bytes[1] & 0x7c) << 1);
tcolor->Green = (((bytes[1] & 0x03) << 3) | ((bytes[0] & 0xe0) >> 5))
<< 3;
tcolor->Blue = (bytes[0] & 0x1f) << 3;
should possibly read
#define CVT(_n) (int)(8.22581f * (_n))
tcolor->Red = CVT((bytes[1] & 0x7c) >> 2);
tcolor->Green = CVT(((bytes[1] & 0x03) << 3) | ((bytes[0] & 0xe0) >> 5));
tcolor->Blue = CVT(bytes[0] & 0x1f);
--
Ray Gardener
Daylon Graphics Ltd.
"Heightfield modeling perfected"
Post a reply to this message
|
|