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

Home » Public Forums » archive » Problem with long integer color when saving a cgwindow to file
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
Problem with long integer color when saving a cgwindow to file [message #87892] Mon, 03 March 2014 08:28 Go to next message
Mats Löfdahl is currently offline  Mats Löfdahl
Messages: 263
Registered: January 2012
Senior Member
Hi,

I'm using cgplot in a cgwindow, specifying the color with a long integer. This works fine. But when I try to save it as a graphics file, I get an error of this type:

Traceback Report from CGPLOT:

% CGDEFAULTCOLOR: Improper input color. It is possible 24-bit colors (LONGs)
are being used in indexed color mode to specify colors.


Here is a minimal example:

cgwindow
cgplot, /add, [1, 2, 3], color = 9243623L
; Fine so far
cgcontrol, output = 'test.jpg'
Re: Problem with long integer color when saving a cgwindow to file [message #87894 is a reply to message #87892] Mon, 03 March 2014 09:05 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Mats Löfdahl writes:

> I'm using cgplot in a cgwindow, specifying the color with a long
integer. This works fine. But when I try to save it as a graphics file,
I get an error of this type:
>
> Traceback Report from CGPLOT:
>
> % CGDEFAULTCOLOR: Improper input color. It is possible 24-bit colors (LONGs)
> are being used in indexed color mode to specify colors.
>
>
> Here is a minimal example:
>
> cgwindow
> cgplot, /add, [1, 2, 3], color = 9243623L
> ; Fine so far
> cgcontrol, output = 'test.jpg'

Congratulations, Mats, you are one in 10,000 IDL programmers using long
integers the way they are suppose to be used!

I spent years tying to get people to do this. Eventually, I just gave it
up as a lost cause. As a result, PostScript output is done (by default)
in indexed color mode rather than decomposed color mode. Coyote routines
mostly don't care. But, here is a case where you want to set your
PostScript device up in decomposed color like everything else these
days.

The way this is done is with cgWindow_SetDefs:

cgWindow_SetDefs, PS_Decomposed=1

I have this command in my IDL startup file, so it is done every time I
start an IDL session. This way there is never any difference between
what I see on my display and what I see in my PostScript file. In my
opinion, anyone using IDL 7.1 or later should do this. (24-bit
PostScript was introduced in IDL 7.1).

cgWindow gets its defaults from the keywords you set with
cgWindow_SetDefs.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Problem with long integer color when saving a cgwindow to file [message #87895 is a reply to message #87894] Mon, 03 March 2014 09:21 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> The way this is done is with cgWindow_SetDefs:
>
> cgWindow_SetDefs, PS_Decomposed=1

By the way, if you don't want to permanently set your PostScript device
up in 24 bit color, you can also set the PS_Decomposed keyword on the
cgControl command to do it for just that one instance.

cgcontrol, output = 'test.jpg', ps_decomposed=1

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Problem with long integer color when saving a cgwindow to file [message #87896 is a reply to message #87895] Mon, 03 March 2014 10:02 Go to previous messageGo to next message
Mats Löfdahl is currently offline  Mats Löfdahl
Messages: 263
Registered: January 2012
Senior Member
Den måndagen den 3:e mars 2014 kl. 18:21:10 UTC+1 skrev David Fanning:
> David Fanning writes:
>
>> The way this is done is with cgWindow_SetDefs:
>
>> cgWindow_SetDefs, PS_Decomposed=1
>
> By the way, if you don't want to permanently set your PostScript device
> up in 24 bit color, you can also set the PS_Decomposed keyword on the
> cgControl command to do it for just that one instance.
>
> cgcontrol, output = 'test.jpg', ps_decomposed=1

Thank you David!

I don't know if I want to change this permanently or not. What are the drawbacks? That is, why isn't it the default? Is it so people will be able to use non-cg commands in a cgwindow with longs used the wrong way?

(I just happened to see the long integer thing today when I was looking for something else. I even hacked up a version of cgcolor over the weekend, that accepted RGB colors given as hexadecimal strings. Worked fine, but felt a bit stupid when I found out about the longs... :o)
Re: Problem with long integer color when saving a cgwindow to file [message #87897 is a reply to message #87896] Mon, 03 March 2014 10:18 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Mats Löfdahl writes:

> I don't know if I want to change this permanently or not. What are the drawbacks? That is, why isn't it the default?

I would say the drawback is that most people don't even realize the
PostScript device can be configured, let alone configured as a 24-bit
device. And, worst of all, the PostScript device is a "sticky"
configuration. Once you set it, it stays set until you change it. If you
use indexed color routines at all, then you are likely to be confused
when all your graphics are showing up in shades of red in your
PostScript device. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL_Object example // help with
Next Topic: Codeless Language Module for IDL for BBEdit/TextWrangler

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

Current Time: Wed Oct 08 15:08:03 PDT 2025

Total time taken to generate the page: 0.00605 seconds