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

Re: Another Color Twist



David Fanning wrote:
> 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.)

Thanks for the advice David. Those of us attempting to write
platform-independent code are sometimes hampered by a lack of available
platforms.

How about if the rules are stated thus:

(1) If you are displaying (TV) or reading (TVRD) 8-bit images,
    color decomposition must be turned OFF (device, decomposed=0).

(2) If you are displaying (TV) or reading (TVRD) 24-bit images,
    color decomposition must be turned ON (device, decomposed=1).

(3) If your IDL version is 5.2 or higher, you should save and restore
    the color decomposition mode (device,
get_decomposed=current_decomposed).

I'm going to make sure my applications conform to these rules.

Cheers,
Liam.

-- 
Liam E. Gumley
Space Science and Engineering Center, UW-Madison
http://cimss.ssec.wisc.edu/~gumley