Re: write_gif problem: Garbled Image [message #15849 is a reply to message #15847] |
Tue, 15 June 1999 00:00  |
David Foster
Messages: 341 Registered: January 1996
|
Senior Member |
|
|
Chris McCarthy wrote:
>
> Hi Folks,
>
> I'm making .gifs of my data using write_gif
> after grabing the display using tvrd() (data are
> displayed using the "display.pro", similar to "tv",
> then annotated)
>
> With a single program I generate 8 images, and occasionally
> one of the .gifs comes out 80% garbled. Top 20% is
> ok. I get the error message:
>
> % TVRD: Unable to create X windows Window completely
> off screen, nothing read.
<http references to example images snipped>
>
> In all cases I am watching the displayed images and they
> look fine. Seems that tvrd() is having a problem with them
> but why? Any ideas would be great. Thanks a lot
>
> Chris McCarthy
> UCLA Astronomy
Chris -
TVRD has problems reading a scrollable draw widget, and can have
problems reading a window if it is iconified or obscured, at least
under X windows. I believe David Fanning has an article on this
at his website: www.dfanning.com .
You might try an approach I've used in a SAFE_TVRD(), which creates
a new pixmap window, uses DISPLAY, COPY=[] to copy the window into
the pixmap, and then uses TVRD() to read from the pixmap. Seems to
work in all situations. If there is a more straightforward approach
to this problem I'd love to see it. Here's the code:
;------- Cut here -------------------------------------------------
; 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
;--------- Cut here -------------------------------------------------
Dave Foster
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
|
|
|