Problem with long integer color when saving a cgwindow to file [message #87892] |
Mon, 03 March 2014 08:28  |
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   |
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 #87897 is a reply to message #87896] |
Mon, 03 March 2014 10:18  |
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.")
|
|
|