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.

This routine is written in the IDL language. Its source code can be found in the file 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.

Calling Sequence




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 to open an MPEG file.


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 .


Set this keyword to display each frame and update the frame slider as frames are loaded.


Set this keyword to cause the frame slider to track the current frame when the animation is in progress. The default is not to track.


Use this keyword to specify a string to be used as the title of the animation widget. If TITLE is not specified, the title is set to "XInterAnimate."

Keywords--Loading Images

The following keywords are used to load images into the animation display. They have no effect when initializing or running animations.


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.)


Set this keyword to display images from the top down instead of the default bottom up.


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:

WINDOW = [Window_Number, X0, Y0, Sx, Sy]

Keywords--Running Animations

The following keywords are used to when running the animation. They have no effect when initializing the animation or loading images.


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.


Use this keyword to specify the horizontal offset, in pixels from the left of the frame, of the image in the destination window.


Use this keyword to specify the vertical offset, in pixels from the bottom of the frame, of the image in the destination window.


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 = BYTARR(64, 64, 16)

READU, unit, H

CLOSE, unit

H = REBIN(H, 128, 128, 16) ; Read the images into variable H.


; Load the images into XINTERANIMATE

XINTERANIMATE, /KEEP_PIXMAPS ; Play the animation.


See Also