Re: More Questions on 24 bit color [message #13335 is a reply to message #13330] |
Tue, 10 November 1998 00:00  |
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.
|
|
|