The XINTERANIMATE procedure displays an animated sequence of images using off-screen pixmaps or memory buffers. The speed and direction of the display can be adjusted using the widget interface.
MPEG animation files can be created either programmatically using keywords to open and save a file, or interactively using the widget interface.
NOTE: Only a single copy of XINTERANIMATE can run at a time. If you need to run multiple instances of the animation widget concurrently, use the CW_ANIMATE compound widget.
This routine is written in the IDL language. Its source code can be found in the file
xinteranimate.pro
in the
lib
subdirectory of the IDL distribution.
Displaying an animated series of images using XINTERANIMATE requires at least three calls to the routine: one to initialize the animation widget, one to load images, and one to display the images. When initialized using the SET keyword, XINTERANIMATE creates an approximately square pixmap or memory buffer, large enough to contain the requested number of frames of the requested size. Images are loaded using the IMAGE and FRAME keywords. Finally, images are displayed by copying them from the pixmap or memory buffer to the visible draw widget.
See CW_ANIMATE for a description of the widget interface controls used by XINTERANIMATE.
A value between 0 and 100 that represents the speed of the animation as a percentage of the maximum display rate. The fastest animation is with a value of 100 and the slowest is with a value of 0. The default animation rate is 100. The animation must be initialized using the SET keyword before calling XINTERANIMATE with a rate value.
The following keywords are used to initialize the animation display. The SET keyword must be provided. Other keywords described in this section are optional; note that they work only when SET is specified.
Set this keyword to a three-element vector [ Sizex , Sizey , Nframes ] to initialize XINTERANIMATE. Sizex and Sizey represent the width and height of the images to be displayed, in pixels. Nframes is the number of frames in the animation sequence. Note that Nframes must be at least 2 frames.
Normally, frames are displayed going either forward or backwards. If the CYCLE keyword is set, the animation reverses direction after the last frame in either direction is displayed.
Set this keyword equal to a string specifying the name of the MPEG file. If no file name is specified, the default value (
idl.mpg
) is used.
Set this keyword equal to zero to have XMANAGER block when this application is registered. By default, NO_BLOCK is set equal to one, providing access to the command line if active command line processing is available. Note that setting NO_BLOCK=0 will cause all widget applications to block, not just this application. For more information, see the documentation for the NO_BLOCK keyword to XMANAGER .
Use this keyword to specify the frame number when loading frames. FRAME must be set to a number in the range 0 to Nframes -1.
Use this keyword to specify a single image to be loaded at the animation position specified by the FRAME keyword. (FRAME must also be specified.)
When this keyword is specified, an image is copied from an existing window to the animation pixmap or memory buffer. (When using some windowing systems, using this keyword is much faster than reading from the display and then calling XINTERANIMATE with a 2D array.)
The value of this parameter is either an IDL window number (in which case the entire window is copied), or a vector containing the window index and the rectangular bounds of the area to be copied. For example:
Set this keyword to delete the offscreen pixmaps or buffers and the animation widget itself. This also takes place automatically when the user presses the "Done With Animation" button or closes the window with the window manager.
Set this keyword to the widget ID of the widget that calls XINTERANIMATE. When GROUP is specified, the death of the calling widget results in the death of XINTERANIMATE.
If this keyword is set, XINTERANIMATE will not destroy the animation pixmaps or buffers when it is killed. Calling XINTERANIMATE again without going through the SET and LOAD steps will play the same animation without the overhead of creating the pixmaps.
Set this keyword to close and save the MPEG file. This keyword has no effect if MPEG_OPEN was not used during initialization.
Enter the following commands to open the file
ABNORM.DAT
(a series of images of a human heart) and animate the images it contains using XINTERANIMATE. For a more detailed example of using XINTERANIMATE, see the example in the "Using IDL Widgets" chapter of
IDL Basics
.
OPENR, unit, FILEPATH('abnorm.dat', SUBDIR=['examples','data']), $
H = REBIN(H, 128, 128, 16) ; Read the images into variable H.
XINTERANIMATE, SET=[128, 128, 16], /SHOWLOAD
;
Initialize XINTERANIMATE.
FOR I=0,15 DO XINTERANIMATE, FRAME = I, IMAGE = H[*,*,I]
;
Load the images into XINTERANIMATE