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

Home » Public Forums » archive » Re: switching PS device from color to b/w?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: switching PS device from color to b/w? [message #31251] Wed, 26 June 2002 10:00 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Liam E. Gumley (Liam.Gumley@ssec.wisc.edu) writes:

> To set the background color, my IMDISP procedure uses code similar to
> the following:
>
> x = [-0.01, 1.01, 1.01, -0.01, -0.01]
> y = [-0.01, -0.01, 1.01, 1.01, -0.01]
> polyfill, x, y, /normal, color=background
>
> where the variable "background" is an index in the color table. This is
> the only way I know of to reliably set the background color on all IDL
> direct graphics devices.

I think this is the only way. It is what I do
in MPI_PLOT too.

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: switching PS device from color to b/w? [message #31253 is a reply to message #31251] Wed, 26 June 2002 09:02 Go to previous messageGo to next message
Liam E. Gumley is currently offline  Liam E. Gumley
Messages: 378
Registered: January 2000
Senior Member
David Fanning wrote:
[stuff deleted]
> And, remember, in PostScript you can have any color background
> you want, as long as it is white. But that is a discussion
> for another day. :-)

To set the background color, my IMDISP procedure uses code similar to
the following:

x = [-0.01, 1.01, 1.01, -0.01, -0.01]
y = [-0.01, -0.01, 1.01, 1.01, -0.01]
polyfill, x, y, /normal, color=background

where the variable "background" is an index in the color table. This is
the only way I know of to reliably set the background color on all IDL
direct graphics devices. The source for IMDISP is available at

http://www.gumley.com/PIP/Free_Software.html

Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
Re: switching PS device from color to b/w? [message #31255 is a reply to message #31253] Wed, 26 June 2002 08:10 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Steve Smith<steven_smith> (nobody@nowhere.com) writes:

> I just found that once you've given the
> /color directive to idl, it retains it,

All PostScript or Z device keywords are "sticky", meaning that they
set the device into a particular state until they are changed.
What you are forgetting is that /COLOR is equivalent to COLOR=1.
If you don't want color you have to set COLOR=0. It is not
uncommon for people who use the "slash" form of keywords
to forget that, since normally they are *not* dealing with
sticky keywords.

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: switching PS device from color to b/w? [message #31256 is a reply to message #31255] Wed, 26 June 2002 08:06 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Ken Mankoff (mankoff@I.HATE.SPAM.cs.colorado.edu) writes:

> What is the difference between:
>
> DEVICE, color=0
> and
> DEVICE, /color, bits_per_pixel=1
>
> Which is more appropriate? Is the only difference for those people who
> argue about black being a color vs. the lack of all colors?

DEVICE, COLOR=0 turns PostScript color output off. BITS_PER_PIXEL=1
simply stores 1 bit per image pixel in the file every time you
do a TV command. It probably stores the lowest bit, so I imagine
an image would look pretty strange.

With color turned off, however, you can only get black
and white output. If you want gray-scale output, you
have to turn COLOR on and load a gray-scale color table.

And, remember, in PostScript you can have any color background
you want, as long as it is white. But that is a discussion
for another day. :-)

Cheers,

David

P.S. All this PostScript stuff is pretty much taken care
of automatically if you use something like PSCONFIG to
set up your PostScript device:

http://www.dfanning.com/programs/psconfig.zip

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: switching PS device from color to b/w? [message #31289 is a reply to message #31256] Mon, 24 June 2002 10:19 Go to previous messageGo to next message
nobody@nowhere.com (S is currently offline  nobody@nowhere.com (S
Messages: 55
Registered: July 2001
Member
I did try it, and it works, thanks again David :) ! However, it doesn't seem
documented well in my docs (5.2 Linux). I've used bits_per_pixel to increase
the color resolution, but never to reduce it. I tried bits_per_pixel=1, and
it's not equivalent to color=0, I still get color output in my PS files. I
actually am reading a true color image (3 channels) and I want to convert it to
greyscale when I write a postscript output. I can specify the size of the page
precisely in idl, so I've a routine to read images and write them to postscript
files with a specific size (no surrounding blank or white space), which most of
my other apps don't allow this freedom (they have fixed page sizes). I don't
know of a better way to do it, but I just found that once you've given the
/color directive to idl, it retains it, I needed a way to reset the ps device
to it's original state, which by default is black and white. device, color=0
will do it, device, /color, bits_per_pixel=1 doesn't. So they can't be equiv-
alent in practice, in theory it sounds like they should be. Maybe David can
explain why they're in not in practice?

On Mon, 24 Jun 2002 10:24:28 -0600, Ken Mankoff
<mankoff@I.HATE.SPAM.cs.colorado.edu> wrote: >
>
> On Sun, 23 Jun 2002, David Fanning wrote:
>> Steve Smith<steven_smith> (nobody@nowhere.com) writes:
>>
>>> Once I write a color image to the ps device (using set_plot,
>>> 'PS'), I cannot get the idl session to re-set to b/w, is there
>>> such a command? Right now I'm starting a second idl session and
>>> doing all the greyscale work there. Basically, I'd like to send an
>>> option like /nocolor to the ps device so it will stop making color
>>> postscript. Is there any such command? I'm using idl 5.2 :(
>>
>> I'd try this:
>>
>> DEVICE, Color=0
>>
>
> Hi David,
>
> What is the difference between:
>
> DEVICE, color=0
> and
> DEVICE, /color, bits_per_pixel=1
>
> Which is more appropriate? Is the only difference for those people who
> argue about black being a color vs. the lack of all colors?
>
> -k.
>
>


--
Steve S.

steve @ NOSPAM sorry i'm tired of spam
remove spaces, NOSPAM and you'll see there is no email address attached :( !
Re: switching PS device from color to b/w? [message #31291 is a reply to message #31289] Mon, 24 June 2002 09:24 Go to previous messageGo to next message
Ken Mankoff is currently offline  Ken Mankoff
Messages: 158
Registered: February 2000
Senior Member
On Sun, 23 Jun 2002, David Fanning wrote:
> Steve Smith<steven_smith> (nobody@nowhere.com) writes:
>
>> Once I write a color image to the ps device (using set_plot,
>> 'PS'), I cannot get the idl session to re-set to b/w, is there
>> such a command? Right now I'm starting a second idl session and
>> doing all the greyscale work there. Basically, I'd like to send an
>> option like /nocolor to the ps device so it will stop making color
>> postscript. Is there any such command? I'm using idl 5.2 :(
>
> I'd try this:
>
> DEVICE, Color=0
>

Hi David,

What is the difference between:

DEVICE, color=0
and
DEVICE, /color, bits_per_pixel=1

Which is more appropriate? Is the only difference for those people who
argue about black being a color vs. the lack of all colors?

-k.
Re: switching PS device from color to b/w? [message #31292 is a reply to message #31291] Mon, 24 June 2002 09:16 Go to previous messageGo to next message
nobody@nowhere.com (S is currently offline  nobody@nowhere.com (S
Messages: 55
Registered: July 2001
Member
thanks David, I'll try that (why didn't I think of it?).

On Sun, 23 Jun 2002 23:37:12 -0600, David Fanning <david@dfanning.com> wrote:
> Steve Smith<steven_smith> (nobody@nowhere.com) writes:
>
>> Once I write a color image to the ps device (using set_plot, 'PS'), I
>> cannot get the idl session to re-set to b/w, is there such a command? Right
>> now I'm starting a second idl session and doing all the greyscale work
>> there. Basically, I'd like to send an option like /nocolor to the ps device
>> so it will stop making color postscript. Is there any such command?
>> I'm using idl 5.2 :(
>
> I'd try this:
>
> DEVICE, Color=0
>
> :-)
>
> Cheers,
>
> David
>
> --
> David W. Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Phone: 970-221-0438, E-mail: david@dfanning.com
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Toll-Free IDL Book Orders: 1-888-461-0155


--
Steve S.

steve @ NOSPAM sorry i'm tired of spam
remove spaces, NOSPAM and you'll see there is no email address attached :( !
Re: switching PS device from color to b/w? [message #31310 is a reply to message #31292] Sun, 23 June 2002 22:37 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Steve Smith<steven_smith> (nobody@nowhere.com) writes:

> Once I write a color image to the ps device (using set_plot, 'PS'), I
> cannot get the idl session to re-set to b/w, is there such a command? Right
> now I'm starting a second idl session and doing all the greyscale work
> there. Basically, I'd like to send an option like /nocolor to the ps device
> so it will stop making color postscript. Is there any such command?
> I'm using idl 5.2 :(

I'd try this:

DEVICE, Color=0

:-)

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: switching PS device from color to b/w? [message #31385 is a reply to message #31256] Tue, 09 July 2002 17:03 Go to previous message
condor is currently offline  condor
Messages: 35
Registered: January 2002
Member
Somone wrote:
>> What is the difference between:
>>
>> DEVICE, color=0
>> and
>> DEVICE, /color, bits_per_pixel=1

From a conceptual point of view, the secon line still uses color, even
though it can distinguish only between two of them because it has only
one bit available. But the second line could in principle produce
blue-on-purple or red-on-green or even yellow-on-yellow. The first
line properly disbles the use of color entirely.

David Fanning <david@dfanning.com> wrote in message news:<MPG.17838661372d6237989911@news.frii.com>...
> And, remember, in PostScript you can have any color background
> you want, as long as it is white. But that is a discussion
> for another day. :-)

Actually, this is incorrect: PostScript doesn't have a concept of a
"background color", you get whatever you plot on a clear (or
transparent) "background". The same PS plot sent to a printer with red
paper in it will not plot a white background onto the red paper -- it
will simply use whatever the background color already is (i.e. red in
this case).

The suggested piece of code simply plots a rectangle in a certain
*foreground* color and then uses that rectangle as a background to
plot something else onto.

All the while there is no "background" anywhere...
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: changing editors?
Next Topic: how to debug floating error

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

Current Time: Wed Oct 08 15:27:41 PDT 2025

Total time taken to generate the page: 0.00644 seconds