[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: TVRD'ing under windows
- Subject: Re: TVRD'ing under windows
- From: David Foster <foster(at)bial1.ucsd.edu>
- Date: Tue, 11 May 1999 17:39:01 -0700
- Newsgroups: comp.lang.idl-pvwave
- Organization: Univ. of Calif San Diego
- References: <email@example.com>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:14705
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.
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
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.
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
firstname.lastname@example.org 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.
; 6-11-97 DSF Check validity of draw widget.
FUNCTION safe_tvrd, draw_widget, xsize, ysize
if (widget_info(draw_widget, /valid_id) eq 0) then begin
endif else if (widget_info(draw_widget, /name) ne 'DRAW') then begin
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
if (old_window ne -1) then wset, old_window
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.
Array = SAFE_TVRD(Draw_widget, Xsize, Ysize)
The widget id of the draw widget which you will be
reading into the array. Note that this is NOT the
The dimensions of the window in the draw widget.
Returns the image read from the draw widget. Returns -1
if the Draw_widget is not a valid draw widget ID.