NAME
        AnimateImages

   DESCRIPTION
        This module is basically an animation builder and player for the Explorer
        environment.  It accepts images in byte lattices (usually snapped out of
        the Render module) and buffers them into an internal image list.  Images
        can be interactively added and deleted from this list as necessary,
        although there is no provision for image reordering.
        
        Once images are accumulated in the list, the sequence can be played
        back in a custom 24-bit (or 12-bit) window on the module's control
        panel using various options.  There are controls for single stepping,
        going forwards and backwards, jumping to a particular image, adjusting
        the animation delay, looping, buffering the images to memory or disk,
        optimizing for speed or memory, etc.  One of the most important options
        is the ability to save single images (or all of them) in the list as SGI RGB
        files (RLE-compressed, of course) for later compilation into a real
        animation file.
        
        The maximum playback speed of the animation is, of course, entirely
        dependent on the host machine's CPU and graphics subsystem.  Here
        are some sample timings for all the combinations of options.  They were
        run using an 8-frame, 640x480 animation on a 200Mhz SGI Indigo2 with
        an XZ graphics card (single-buffering = 24-bit and double-buffering =
        12-bit):
        
        Singlebuffering
             to memory
                  optimized for speed
                       updating frame slider:   29.52 fps
                       not updating frame slider:   38.25 fps
                  optimized for memory
                       updating frame slider:   8.95 fps
                       not updating frame slider:   9.93 fps
             to disk
                  optimized for speed
                       updating frame slider:   13.31 fps
                       not updating frame slider:  15.44 fps
                  optimized for memory
                       updating frame slider:   7.09 fps
                       not updating frame slider:   7.90 fps
        
        Doublebuffering
             to memory
                  optimized for speed
                       updating frame slider:   27.30 fps
                       not updating frame slider:   35.72 fps
                  optimized for memory
                       updating frame slider:   8.87 fps
                       not updating frame slider:   9.90 fps
             to disk
                  optimized for speed
                       updating frame slider:   12.27 fps
                       not updating frame slider:   15.29 fps
                  optimized for memory
                       updating frame slider:   6.98 fps
                       not updating frame slider:   7.85 fps

   INPUTS

      Image -- Lattice (Opt.)
         (2-D, 3..4-vector, byte, uniform).
         This is an input image lattice.

   WIDGETS

      View Window? -- Option Menu
         This determines whether the image window is visible or not.  Most
         functions on the control panel can still be used even if the window is
         not visible.  The notable exceptions being the "Refresh", "Prev",
         "Play / Pause", and "Next" buttons.

      Image Mode -- Option Menu
         This sets the mode for adding new images to the image list.  In "Add"
         mode, whenever a new image lattice is received on the Image port it is
         appended  to the end of the image list.  In "Freeze" mode, new lattices
         are just ignored.

      Image # -- Slider
         This is the current image number.  It can be used to go directly to any
         particular image.

      Play Mode -- Option Menu
         This sets the direction for playing the images.  They can be played
         forwards, backwards, or in a forward and backward sequence (rocking).

      Loop? -- Option Menu
         This determines whether the images are played in a continuous looping
         manner.  In "Forward" mode, once the last image is reached it starts
         over at the first image.  In "Backward" mode, once the first image is
         reached it starts over at the last image.  In "Rock" mode, once the end
         or the beginning of the image list is reached it switches playing
         directions.  The "Loop?" setting will also affect the behavior of the
         "Prev" and "Next" buttons when reaching the bounds of the image list.

      Step -- Slider
         This is the increment to be applied to the current image number for
         going forward or backward between images.  It affects the functionality
         of the "Prev", "Play / Pause", and "Next" buttons.

      Delay (Sec.) -- Slider
         This is the number of seconds to wait between playing images.

      Save -- Text
         This port is used in conjunction with the "Save Current Image"
         selection in the "Options" menu; it probably should not be used
         directly.  The "Save Current Image" selection prompts for a name which
         will be used to save the current image as an SGI RGB file (with RLE
         compression).

      Save All -- Text
         This port is used in conjunction with the "Save All Images" selection in
         the "Options" menu; it probably should not be used directly.  The
         "Save All Images" selection prompts for a name which will be used as
         the basis to save all the images in the image list as SGI RGB files (with
         RLE compression).  For each image, the entered name is appended with
         the image number (starting at 1) and a ".rgb" extension.

      Background Color -- Text
         This port is used in conjunction with the "Black Background" and
         "White Background" selections in the "Options" menu.  They set the
         color of the background behind the images to black and white
         respectively.  A string parameter can be connected to this port
         specifying three numbers (ranging from 0.0 to 1.0) for the red, green,
         and blue components of the background color.

      Center Images? -- Option Menu
         This port is used in conjunction with the "Center Images" and
         "Don't Center Images" selections in the "Options" menu.  They
         determine whether or not the images are centered within the entire
         image window.  The default is to place them in the lower left-hand
         corner.

      Update Frame Slider? -- Option Menu
         This port is used in conjunction with the "Update Frame Slider" and
         "Don't Update Frame Slider" (the default) selections in the "Misc."
         menu.  They determine whether the "Image #" slider (the current frame)
         is updated as an animation is playing.  Not updating this slider can
         result in a significant speed increase with certain options.

      Window Mode -- Option Menu
         This port is used in conjunction with the "Single-buffered Window" (the
         default) and the "Double-buffered Window" selections in the "Image"
         menu.  They determines how the images will be drawn in the image
         window.  Double-buffering mode will result in smoother animation, but
         lower color resolution (12-bit).  Single-buffering mode will result in
         somewhat jerky playback, but full color resolution (24-bit).  Also, the
         speed using double-buffering mode will be somewhat less on graphics
         hardware that doesn't do it in 24-bit, since the color resolution of the
         original 24-bit images must be scaled down before they are displayed.

      Buffer Storage -- Text
         This port is used in conjunction with the "Buffer Images To Memory"
         (the default) and "Buffer Images To Disk" selections in the "File" menu.
         If disk buffering is selected then a file requester pops up asking for
         a valid directory to store the image buffers.  Changing from one
         buffering mode to another automatically switches over all the buffered
         images so that nothing gets lost.

      Optimize -- Option Menu
         This port is used in conjunction with the "Optimize For Speed" (the
         default) and "Optimize For Memory" selections in the "Misc." menu.
         When optimizing for speed, it tells AnimateImages to store each image
         using four bytes per pixel.  When optimizing for memory, it specifies
         using only three bytes per pixel for each image.  Using three bytes per
         pixel is more memory/disk efficient (the fourth alpha component is not
         really used anyway), but it slows down the playback speed since this
         "compressed" format must be uncompressed before display.  Speed
         can improve significantly by using four bytes per pixel instead of three!
         Note: Changing this setting doesn't affect the images already in the
         image list, only new ones that are later added.

      Timing -- Option Menu
         This port is used in conjunction with the "Print Play Speed" and
         "Don't Print Play Speed" (the default) selections in the "Misc." menu.
         They determine whether timing information is printed to show playback
         speed of an animation sequence.  If selected then it prints the number
         of frames displayed, the execution time, and the number of frames per
         second achieved during a run.

      Status -- Text
         This string contains status information for AnimateImages.  It shows
         how many bytes have been allocated for the image list, the mode of the
         image window (single/double-buffered), and how the images have been
         buffered (memory/disk).

      Button Window 1 -- Drawing Area
         This is a custom drawing area containg the "Prev", "Play / Pause", and
         "Next" buttons.  The buttons perform the following tasks:
         
            Prev - Go to the previous image considering the "Step" value.  If
               looping is enabled then stepping before the first image will cause a
               wrap-around to the end of the image list.
            Play / Pause - Play the images based on the "Play Mode" and the
               "Step" value.  Pressing this button again while the images are
               playing will pause the sequence at the current image.
            Next - Go to the next image considering the "Step" value.  If looping
               is enabled then stepping after the last image will cause a wrap-
               around to the beginning of the image list.

      Button Window 2 -- Drawing Area
         This is a custom drawing area containg the "Add", "Delete", and
         "Delete All" buttons.  The buttons perform the following tasks:
         
            Add - Forces the addition of an image lattice on the "Image" port to
               the end of the image list regardless of the "Image Mode".
            Delete - Deletes the current image from the image list.
            Delete All - Deletes all the images in the image list.
         
         NOTE: There is no undo capability so caution should be taken when
         deleting images.

      Button Window 3 -- Drawing Area
         This is a custom drawing area containing the "Refresh" button.
         Pressing it updates the contents of the image window.  If the image
         window is blocked by another window and then exposed, it will not be
         automatically refreshed.  Jumping to another image, playing the
         animation, or deleting an image are the other ways that it will be
         refreshed.

   KNOWN PROBLEMS
      The module may only work on SGI machines because it uses the Iris GL
      library for displaying the images, the SGI image library for saving them,
      and the SGI system call "sginap" to create the delay.  When a window is
      obscured then exposed, it will not be automatically refreshed.  A future
      version may alter this behavior, thus eliminating the need for a "Refresh"
      button.  Doublebuffering is hardcoded as being 12-bit for the XZ card.
      This will change in the next version to take advantage of better graphics
      hardware.  There are no known bugs.

   SEE ALSO
      ExportImage, WriteImg, WriteMovie, WriteSGI

      -
            
      Hans Vahlenkamp (Hans.Vahlenkamp@noaa.gov)
      Geophysical Fluid Dynamics Laboratory / NOAA
      Princeton University Forrestal Campus
      http://www.gfdl.noaa.gov