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

Home » Public Forums » archive » Re: More Questions on 24 bit color
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: More Questions on 24 bit color [message #13330] Tue, 10 November 1998 00:00
Kevin Ivory is currently offline  Kevin Ivory
Messages: 71
Registered: January 1997
Member
David Fanning wrote:
> Oh, sorry, Kevin. I think I am using the IDL 5.2 Color_Quan,
> which has been fixed. Earlier versions did not work on
> 24-bit machines! While you are waiting for the official
> new version you can make yours work by setting the Colors
> keyword to 256.
>
> image2D = Color_Quan(snapshot, 1, r, g, b, Colors=256)

Thanks, David! This is great. Now I don't have to open a virtual terminal
with 8 bits/pixel whenever I need a GIF image of my IDL window.

In fact, my next wish is that RSI would finally support 16 bits/pixel
on Unix. That is my default - I have to open a virtual terminal with
24 bits/pixel every time I want use IDL's graphical abilities :-(

Best regards,
Kevin
--
Kevin Ivory Tel: +49 5556 979 434
Max-Planck-Institut fuer Aeronomie Fax: +49 5556 979 240
Max-Planck-Str. 2 mailto:Kevin.Ivory@linmpi.mpg.de
D-37191 Katlenburg-Lindau, GERMANY http://www.gwdg.de/~kivory2/

> Note: A copy of this article was e-mailed to the original poster.
Same here.
Re: More Questions on 24 bit color [message #13331 is a reply to message #13330] Tue, 10 November 1998 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Kevin Ivory (Kevin.Ivory@linmpi.mpg.de) writes:

> David Fanning wrote:
>> snapshot = TVRD(True=1)
>> image2D = Color_Quan(snapshot, 1, r, g, b)
>> Write_Gif, 'neat.gif', image2D, r, g, b
>
> I've never really got tvrd() to work on Linux XFree86 with 24 bpp.
> I figured it was the same bug that doesn't let me grab a window
> correctly with xv or gimp. That why I was quite happy to see David
> post a few lines that should work. Alas, I get some kind of an error:
>
> IDL> snapshot = TVRD(True=1)
> IDL> help,snapshot
> SNAPSHOT BYTE = Array[3, 651, 921]
> IDL> image2D = Color_Quan(snapshot, 1, r, g, b)
> % COLOR_QUAN: Value of number of colors is out of allowed range.
> % Execution halted at: $MAIN$
>
> The message doesn't help me much. Any ideas?

Oh, sorry, Kevin. I think I am using the IDL 5.2 Color_Quan,
which has been fixed. Earlier versions did not work on
24-bit machines! While you are waiting for the official
new version you can make yours work by setting the Colors
keyword to 256.

image2D = Color_Quan(snapshot, 1, r, g, b, Colors=256)

Cheers,

David

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

Note: A copy of this article was e-mailed to the original poster.
Re: More Questions on 24 bit color [message #13332 is a reply to message #13330] Tue, 10 November 1998 00:00 Go to previous message
Kevin Ivory is currently offline  Kevin Ivory
Messages: 71
Registered: January 1997
Member
David Fanning wrote:
> snapshot = TVRD(True=1)
> image2D = Color_Quan(snapshot, 1, r, g, b)
> Write_Gif, 'neat.gif', image2D, r, g, b

I've never really got tvrd() to work on Linux XFree86 with 24 bpp.
I figured it was the same bug that doesn't let me grab a window
correctly with xv or gimp. That why I was quite happy to see David
post a few lines that should work. Alas, I get some kind of an error:

IDL> snapshot = TVRD(True=1)
IDL> help,snapshot
SNAPSHOT BYTE = Array[3, 651, 921]
IDL> image2D = Color_Quan(snapshot, 1, r, g, b)
% COLOR_QUAN: Value of number of colors is out of allowed range.
% Execution halted at: $MAIN$

The message doesn't help me much. Any ideas?
Kevin
--
Kevin Ivory Tel: +49 5556 979 434
Max-Planck-Institut fuer Aeronomie Fax: +49 5556 979 240
Max-Planck-Str. 2 mailto:Kevin.Ivory@linmpi.mpg.de
D-37191 Katlenburg-Lindau, GERMANY http://www.gwdg.de/~kivory2/
Re: More Questions on 24 bit color [message #13335 is a reply to message #13330] Tue, 10 November 1998 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
David B. Wolff (dwolff@ariel.met.tamu.edu) writes:

> I am having similar problems using 24-bit color on a Linux system. I was
> able to get IDL
> to properly display my colors using "Device,decomposed=0" as the first call
> in my
> program; however, if I then try to do a tvrd() to write a gif or other
> 8-bit image format,
> the color palette is not preserved. Does anyone know how to get tvrd() to
> read properly.
>
> If you have some suggestions, please e-mail them to me at:
> dwolff@ariel.met.tamu.edu.

Good question, Dave. It reminds me that I have been going to
write an article about this.

On a 24-bit device, if you issue this command:

snapshot = TVRD()

what you will get will be a 2D array in which the pixel value
is the maximum pixel value in each of the red, green, and
blue channels. In other words, if the actual pixel value
is [240, 29, 149], what will be returned is the pixel value
240. (Remember that on a 24-bit display the pixel value
is actually expressed as a color triple.)

Clearly (pun), this will result in a strange image when
you write a GIF file.

Now, what do you need to create a color GIF file? You need
a 2D image and the color vectors that express the colors
for that image. The secret to getting what you want on
a 24-bit device is the COLOR_QUAN function, which takes
a 3D (or 24-bit image) and reduces it to a 2D image and
the color vectors to express the colors for the image.
Great, all we need is that 24-bit image. And you get it
like this:

snapshot = TVRD(True=1)

Then, to make the GIF file:

image2D = Color_Quan(snapshot, 1, r, g, b)
Write_Gif, 'neat.gif', image2D, r, g, b

Cheers,

David

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

Note: A copy of this article was e-mailed to the original poster.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: GUI Builder limited to Windows platform (LONG)
Next Topic: Re: using mpfit

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

Current Time: Thu Oct 09 21:21:45 PDT 2025

Total time taken to generate the page: 0.00561 seconds