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

Home » Public Forums » archive » Re: X and tvrd color scaling problem
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: X and tvrd color scaling problem [message #37531] Mon, 05 January 2004 21:33 Go to next message
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
> The solution depends on what it is you are trying
> to do, but let's just say this is why some of us
> invented programs like TVREAD and TVIMAGE. :-)

Just noticed something. In your handy dandy web page "Strange TVRD
Results," you referred your TVImage procedure, but not TVRead. Might be
worth mentioning in there somewhere. I didn't realize that a better
tvrd existed until now.

Mike
Re: X and tvrd color scaling problem [message #37532 is a reply to message #37531] Mon, 05 January 2004 21:22 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Michael Wallace writes:

> I'm having a strange problem with tvrd(). When using the Z buffer
> everything behaves as I expect. However, when using X tvrd() doesn't
> seem to scale the colors correctly.
>
> For an example, I created a new window and added a colorbar. In the
> window, everything looks normal. But, if I grab the image with tvrd()
> and then immediately display it with tv, the colors get scaled
> incorrectly and there's a lot of white which is index 255 of the color
> table I'm using.
>
> ; create a window and a colorbar (a la Coyote)
> device, DECOMPOSE = 0
> loadct, 39
> window, XSIZE = 400, YSIZE = 400
> colorbar, format = '(A1)'
>
> ; everything looks normal so far...
> ; grab the image and display it with tv
> image = tvrd()
> tv, image
>
> ; what happened?! the scaling is funky and there's a lot of white!
>
>
> However, if I use the Z buffer, everything behaves as I expect.
>
> ; create an image and a colorbar (a la Coyote)
> device, DECOMPOSE = 0
> loadct, 39
> set_plot, 'Z', /COPY
> device, SET_RESOLUTION = [400, 400]
> colorbar, format = '(A1)'
>
> ; grab the image and switch back to X to display it
> image = tvrd()
> set_plot, 'X'
> window, XSIZE = 400, YSIZE = 400
> tv, image
>
> ; the image looks normal and there's no weird scaling
>
>
> What gives? Why doesn't the X method capture the image correctly?

The X window has a depth of 24 bits, whereas the Z buffer
has a depth of 8 bits. When you use TVRD in the way you
are on a 24-bit device the value that is returned to you
as the "value" of that pixel is the largest of the
values in the red, green, and blue planes. Not what you
want at all.

The solution depends on what it is you are trying
to do, but let's just say this is why some of us
invented programs like TVREAD and TVIMAGE. :-)

Something like this:

image = TVRD(True=1)

Followed by TV, image, TRUE=1 should work.

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: X and tvrd color scaling problem [message #37533 is a reply to message #37532] Mon, 05 January 2004 21:16 Go to previous messageGo to next message
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
Well, it turns out I was able to answer my own question with a little
help from a new favorite web site of mine.

http://www.dfanning.com/color_tips/strange_tvrd.html

Since I'm on a 24-bit display, I need to do this instead:
image = tvrd(true = 1) ; grab the image
tvimage, image ; just say no to tv!

Mike

P.S. David, thanks for maintaining that web site of yours. Who knows
how long I might have searched for that answer without it...
Re: X and tvrd color scaling problem [message #38736 is a reply to message #37532] Fri, 26 March 2004 08:44 Go to previous message
Alvin is currently offline  Alvin
Messages: 4
Registered: March 2004
Junior Member
Hi David:

I have a different problem. I can't capture the color white from a window
using tvread. Every other color works fine but after I redisplay the
captured image, the white is all messed up!
Any idea?

Alvin.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Is_netCDF Function
Next Topic: Re: Transparent IDLgrImage ?

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

Current Time: Sat Oct 11 13:55:36 PDT 2025

Total time taken to generate the page: 1.11962 seconds