[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Another Color Twist



Hi Folks,

Because I know your day, like mine, just doesn't feel 
complete without learning about yet another little
color twist in IDL, I have this observation from a
course I am teaching this week:

People who pay attention to this newsgroup (except
the ones who count, apparently) have heard me bemoan
the fact that 24-bit images cannot be displayed
correctly on Macs and PCs unless color decomposition
is ON. If color decomposition is OFF, the image
pixel values are always routed through the color
tables, where--if you have anything other than a
gray-scale color table loaded--your colors get
totally screwed up.

What I learned yesterday is that the same problem
exists in reverse, but only on Macintosh computers.
That is to say, suppose you have a 24-bit image
displayed correctly on your 24-bit display. But
you have color decomposition turned OFF and a 
color table loaded (say, to correctly display
a companion 2D image). Now suppose you wish to
make a JPEG color image of the window holding the
24-bit image. The proper way to get a screen
dump or snapshot of the window is like this:

   snapshot = TVRD(True=1)

Snapshot will now be a 24-bit image holding the
color information. Well, at least it will be on 
UNIX and PCs. On Macintosh computers, it will
be a 24-bit image holding the color information
obtained not from the image, but from the *color
tables*. Hence, the resulting JPEG image will
be totally screwed up. 

The trick is to be sure color decomposition
is turned ON whenever you fool around with a
24-bit image. (Which, now that I think about
it, is surely the message RSI is trying to get
across to us. But it seems like an awful lot
of work to me. Couldn't TV and TVRD be made
just a *little* bit smarter when it comes to
24-bit images? Please.)

In any case, here is one more reason (if you
needed another) to become intimately familiar
with the !Version system variable. :-)

Cheers,

David

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