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

Home » Public Forums » archive » TVRD'ing under windows
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
TVRD'ing under windows [message #15261] Thu, 06 May 1999 00:00 Go to next message
philaldis is currently offline  philaldis
Messages: 32
Registered: March 1999
Member
I'm having trouble tvrd'ing under windows, when I'm running 16 bit
mode, and using decomposed colour. If I display an image, and then
tvrd it back in and the tv that image, I get a garbled mess. The only
way I can get a representation of what is on the screen is to set it
into 24 bit mode, image=tvrd (true=1) and then tv, image, true=1.

I'm not really sure what's going on. Is this anything to do with what
David was saying a while bakc, that when you're using decomposed
colous, it runs stuff through the table or something.

Cheers,
Phil
Re: TVRD'ing under windows [message #15348 is a reply to message #15261] Tue, 11 May 1999 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
David Foster (foster@bial1.ucsd.edu) writes:

> I ran into this problem years ago under X-Windows (Sun OS and Solaris),
> and at that time it was a bug, in that even with backing store
> provided by IDL TVRD() could produce unexpected results if the window
> was obscured or iconified, especially if the draw widget was
> scrollable.
>
> I got around the problem by using DEVICE, COPY=[] to copy the window
> contents to a pixmap, and then TVRD() from that pixmap. Works quite
> well, at least under SunOS/Solaris.
> I've attached my SAFE_TVRD.PRO and SAFE_TVRD.DOC files.

Alas, even Safe_TVRD won't help with this problem, since
it has to do with how windows on 24-bit devices work. You
will have the same problem reading off a pixmap as you will
off the display window. What you *might* be able to do,
depending upon how "device-independently" you write your
graphics display code, is display your graphics in the
Z-graphics buffer. You can take a TVRD() from this
window and end up with a 2D array of index values, which
is what you might be expecting.

You can find more information about this problem here:

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

By the way, I'm told that there are actually graphics
display cards (e.g. a DEC Alpha with a video card 40T)
that store their data as BGR instead of RGB. On those
cards, you will have to switch things around to get
what you expect. Don't you love computers? Sigh...

On a happier note, I finally got some folks at RSI
listening to my complaints about having to set
Device, Decomposed=1 (or load color table 0) to get
a 24-bit image to display with the correct colors
on a PC in 24-bit color mode. No promises, but at
least they are listening. Stay tuned. :-)

In the meantime, you can use TVImage, which puts you
in the proper mode automatically (and switches you
back if you are running IDL 5.2, where the keywords
are available to do it).

http://www.dfanning.com/programs/tvimage.pro

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
Re: TVRD'ing under windows [message #15349 is a reply to message #15261] Tue, 11 May 1999 00:00 Go to previous message
David Foster is currently offline  David Foster
Messages: 341
Registered: January 1996
Senior Member
Phil Aldis wrote:
>
> I'm having trouble tvrd'ing under windows, when I'm running 16 bit
> mode, and using decomposed colour. If I display an image, and then
> tvrd it back in and the tv that image, I get a garbled mess. The only
> way I can get a representation of what is on the screen is to set it
> into 24 bit mode, image=tvrd (true=1) and then tv, image, true=1.
>
> I'm not really sure what's going on. Is this anything to do with what
> David was saying a while bakc, that when you're using decomposed
> colous, it runs stuff through the table or something.
>
> Cheers,
> Phil

Hi Phil -

I ran into this problem years ago under X-Windows (Sun OS and Solaris),
and at that time it was a bug, in that even with backing store
provided by IDL TVRD() could produce unexpected results if the window
was obscured or iconified, especially if the draw widget was
scrollable.

I got around the problem by using DEVICE, COPY=[] to copy the window
contents to a pixmap, and then TVRD() from that pixmap. Works quite
well, at least under SunOS/Solaris.

I've attached my SAFE_TVRD.PRO and SAFE_TVRD.DOC files.

Dave
--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2240
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~

; SAFE_TVRD.PRO 6-11-97 DSFoster
;
; This function is a safer version of IDL's TVRD() function. First,
; there was a bug related to the reading from a scrollable draw. Also,
; the TVRD() function uses an X routine that has problems if the
; window is obscured or iconified. This routine uses the DEVICE, COPY=
; command to first copy the window contents to a new window pixmap,
; and then reads from this pixmap into the array.
;
; Modifications
;
; 6-11-97 DSF Check validity of draw widget.

FUNCTION safe_tvrd, draw_widget, xsize, ysize

on_error, 2

if (widget_info(draw_widget, /valid_id) eq 0) then begin
return, -1
endif else if (widget_info(draw_widget, /name) ne 'DRAW') then begin
return, -1
endif else begin
old_window = !d.window
window, xsize=xsize, ysize=ysize, /free, /pixmap ; Create new window

widget_control, draw_widget, get_value=window
device, copy=[0,0, xsize,ysize, 0,0, window] ; Copy into new window

image = tvrd() ; Read into array
wdelete, !d.window
if (old_window ne -1) then wset, old_window
return, image
endelse

END

SAFE_TVRD

This function replaces IDL's TVRD() function for reading the
contents of a window into an array. The TVRD() function returns
unexpected results if the window is scrollable or is obscured
onscreen. This function uses IDL's DEVICE, COPY=[] function
to more safely read the window contents.

Calling Sequence

Array = SAFE_TVRD(Draw_widget, Xsize, Ysize)

Arguments

Draw_widget

The widget id of the draw widget which you will be
reading into the array. Note that this is NOT the
window id!

Xsize, Ysize

The dimensions of the window in the draw widget.

Outputs

Array

Returns the image read from the draw widget. Returns -1
if the Draw_widget is not a valid draw widget ID.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL 5.0.2 with windows 98
Next Topic: Reclicing image volumes

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

Current Time: Wed Oct 08 11:44:45 PDT 2025

Total time taken to generate the page: 0.00446 seconds