[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Baffled by color postscript



David R. Wyble (drwpci@cis.rit.edu) writes:

> OK, I've been through many of David's great web pages, and through the portion
> of his book related to the subject. Still, I get only monochrome output, or
> none at all. Here is what I am doing. Note that this works perfectly for the X
> display (that part between the X-only comments). Running on SGI Octane, IDL
> 5.0 MIPS
> 
> ; x,y are 1xn vectors of data
> ; my_rgb is a 3xn byte values of RGBs for each respective
> ;    element of x,y
> 
> ; save current device, open postscript
> thisdevice = !d.name
> set_plot, 'PS', /copy
> device, xsize=6, ysize=6, /inches, bits_per_pixel=24, /color
> 
> ; plot the axes
> plot, x, y, /nodata, xrange=[0,20], yrange=[0,20], title=chartTitle
> saveColor = !p.color
> 
> ;;;; X-only code starts
> ; loop through the data rgb_index() returns the 24 bit color
> for i = 0, l-1 do begin
> 	!p.color = rgb_index(my_rgb[0,i],my_rgb[1,i],my_rgb[2,i])
> 	plots, x[i], y[i], psym=4
> end
> 
> ; plot a line at unity, make it the default color
> !p.color = saveColor
> oplot, [0,20],[0,20]
> 
> ;;;; X-only code ends
> 
> ; close it up and reset the device
> device, /close_file
> set_plot, thisdevice
> 
> 
> Any ideas what is wrong? This code produces a postscript file with only the
> axes and the line at [0,20],[0,20]. From experimenting with SYMSIZE, I believe
> the points are actually plotting, but they are always white. (When I set
> SYMSUZE=20, portions of the axes are overwritten, presumably by the large data points.)

Well, I'm going to go a little bit out on a limb here,
because the IDL documentation is either silent or (often,
at least to me) ambiguous on the subject.

Here is where I am the shakiest. I'm going to assert that
even if you COULD produce 24-bit PostScript output (and
I don't think you can from within IDL), there probably
isn't a printer around that could print it. I say this
based on my own understanding of printing technology and
a real quick look around the web for 24-bit color printers.
The best I found was a printer that claims to print in 
4-color CMYK color. Anyway, if someone knows better I'd love
to hear from you.

But that said, I am quite certain that you cannot get 24-bit
PostScript color out of IDL. (This may not even be an IDL
problem. I think it likely that the PostScript Level 2
specification doesn't allow it, although I don't know this
to be true.)

The fact that you can type these commands is totally misleading:

   Set_Plot, 'PS'
   Device, Bits_per_Pixel=24

If you look, the bits per pixel for the device has been set to
8, the largest value allowed:

   Help, /Device

This is output from my Windows NT 24-bit color machine:

   IDL> set_plot, 'ps'
   IDL> device, bits_per_pixel=24
   IDL> help, /device
   Available Graphics Devices: CGM HP NULL PCL PRINTER PS WIN Z
   Current graphics device: PS
    File: <none>
    Mode: Portrait, Non-Encapsulated, EPSI Preview Disabled, Color Disabled
    Offset (X,Y): (1.905,12.7) cm., (0.75,5) in.
    Size (X,Y): (17.78,12.7) cm., (7,5) in.
    Scale Factor: 1
    Font Size: 12
    Font Encoding: AdobeStandard
    Font: Helvetica	TrueType Font: <default>
    # bits per image pixel: 8

What you CAN do in IDL is write a 24-bit image to a PostScript
file, but you do it in the same way you display a 24-bit image
on an 8-bit display: by writing the 8-bit pixel values to 
different channels:

   TV, image24, True=1

I don't know how this is actually done in PostScript, but the
output certainly looks like what I expect it to look like
when I open the file in a PostScript previewer.

What I have NEVER been able to do is draw a yellow plot on
a charcoal background, by doing something like this:

   Plot, Findgen(11), Color='00ffff'xL, Background='707070'xL

Even though this command works perfectly well on a 24-bit display.
In fact, I have NEVER been able to see any PostScript output
at all when using this this kind of color specification.

I don't think it is drawing white on white, because I have
tried putting a black image behind the plot and I still don't
see anything. I think, basically, the commands are just
not being written into the file. Or, they are being written
in a way that is not generating an error, but cannot be
interpreted either. I hope someone who knows how this works
can respond.

So, what can you do?

You might try using Color_Quan to convert your RGB color
values into a color table that you could load and use with
the PostScript output. For example, something like this:

   IDL> r=[70, 255, 0] & g=[70, 255, 255] & b=[70, 0, 0]
   IDL> val = color_quan(r, g, b, rr, gg, bb)
   IDL> tvlct, rr, gg, bb
   IDL> Plot, Findgen(11), Color=val[1], Background=val[0], /NoData
   IDL> Oplot, Findgen(11), Color=val[2]

I think that is about the only thing that has a chance of
working.

Best Regards,

David

-- 
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155

[Note: This follow-up was e-mailed to the cited author.]