POV-Ray : Newsgroups : povray.general : Grayscale PNG read error in POV-Ray 3.5 Server Time
5 Nov 2024 11:20:20 EST (-0500)
  Grayscale PNG read error in POV-Ray 3.5 (Message 1 to 2 of 2)  
From: Ray Gardener
Subject: Grayscale PNG read error in POV-Ray 3.5
Date: 4 Apr 2003 20:30:05
Message: <web.3e8e30c1751144cdfe4e4f170@news.povray.org>
I am able to reliably reproduce a bug in POV-Ray 3.5
which affects Win32 and probably on other platforms.

Loaded imagemaps using grayscale PNG files
of 4 bpp or less appear near-black.

The bug is in the module png_pov.cpp,
function Read_Png_Image(), near line 1550.
The problem is that the colormap's RGB color
channels are mapped directly to palette indices,
which is okay for 8-bit files but not for
lower bit depths, since the palette indices
don't go all the way up to 255. e.g., A 4-bit file
will have a maximum white color of rgb(15,15,15)
instead of rgb(255,255,255).

The code fragment

    for (index = 0; index < cmap_len; index++)
    {
      cmap[index].Red =
      cmap[index].Green =
      cmap[index].Blue = index;
      cmap[index].Filter = 0;
      cmap[index].Transmit = 0;
    }

should read

    for (index = 0; index < cmap_len; index++)
    {
      cmap[index].Red =
      cmap[index].Green =
      cmap[index].Blue = index * 255 / (cmap_len - 1);
      cmap[index].Filter = 0;
      cmap[index].Transmit = 0;
    }


Ray Gardener
Daylon Graphics Ltd.
http://www.daylongraphics.com/products/leveller/
"Heightfield modeling perfected"


Post a reply to this message

From: Warp
Subject: Re: Grayscale PNG read error in POV-Ray 3.5
Date: 4 Apr 2003 21:02:25
Message: <3e8e3931@news.povray.org>
Ray Gardener <ray### [at] daylongraphicscom> wrote:
>       cmap[index].Red =
>       cmap[index].Green =
>       cmap[index].Blue = index;

> should read

>       cmap[index].Red =
>       cmap[index].Green =
>       cmap[index].Blue = index * 255 / (cmap_len - 1);

  This looks like a genuine bug, indeed.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

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