comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Why does color change to b/w when using PNG?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Why does color change to b/w when using PNG? [message #38716 is a reply to message #38540] Fri, 19 March 2004 14:12 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Lawrence Bleau writes:

> Previously, we were using the ps device (SET_PLOT,'PS') and generating
> PostScript files for each plot. We now want to generate PNG files as well.
>
> I copied all the IDL code that generated the PostScript file, changed
> SET_PLOT,'PS' to SET_PLOT,'Z', removed most of the device commands (since
> few of them apply to the Z device), and ran the IDL code to test it out.
>
> It ran without errors, which is the good news. The bad news is that the
> output PNG file seems to be almost all black, with a few white dots where
> the data should be, and absolutely no color; the original had color all
> over the place. Sounds like a simple case of the color table being wrong,
> I thought.
>
> But wait: the PS device used a color table, too, and I didn't change that
> part of the code at all! Here's the code that sets up the color table:
>
> ; set up a simple color table
>
> bbc = 255b
> bfg = 0b
>
> red = [bbc, bfg, 255b, 0b, 0b, 0b, 255b, 255b, 255b, 127b, 0b, $
> 0b, 127b, 255b, 85b, 170b]
> gre = [bbc, bfg, 0b, 255b, 0b, 255b, 0b, 255b, 127b, 255b, 255b, $
> 127b, 0b, 0b, 85b, 170b]
> blu = [bbc, bfg, 0b, 0b, 255b, 255b, 255b, 0b, 0b, 0b, 127b, $
> 255b, 255b, 127b, 85b, 170b]
>
> tvlct, red, gre, blu
> tvlct, bfg, bfg, bfg, !d.n_colors-1
>
> I checked, and print,!d.n_colors-1 displays 255.
>
> So, what's different between these two plot types (PS vs. PNG) that would
> cause the same code to produce different results?

I think if you stay away from using color index 0 and color index 255
in your color tables you will be fine. In PostScript, of course, you
can have any background color you like as long at it is white. (Another
way to say this is that PostScipt ignores the color loaded in to
index 255.) PNG is not so particular. What happens when you run this
program on your display? What does it look like then? That is what it
is going to look like in PNG, probably.

Anyway, this kind of thing is done all the time (even, I suppose,
on OpenVMS systems). You really should be able to make identical
plots without much difficulty. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting
Coyote's Guide to IDL Programming: http://www.dfanning.com/
[Message index]
 
Read Message
Read Message
Previous Topic: Color table editor
Next Topic: Re: Color table editor

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 14:29:42 PDT 2025

Total time taken to generate the page: 0.47915 seconds