Class GifImage


  • public class GifImage
    extends java.lang.Object
    This class can be used to read animated gif image files and extract the individual images of the animation sequence.
    Author:
    Michael Berry, Neil Brown Copyright (c) 2011,2013,2014,2018,2021
    • Constructor Summary

      Constructors 
      Constructor Description
      GifImage​(GifImage copyFrom)
      Copy the given GifImage.
      GifImage​(java.lang.String file)
      Set the image of the actor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      greenfoot.GreenfootImage getCurrentImage()  
      java.util.List<greenfoot.GreenfootImage> getImages()
      Get all the images used in the animation
      boolean isRunning()
      Determines whether the animation is running
      void pause()
      Pause the animation.
      void resume()
      Resume the animation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GifImage

        public GifImage​(java.lang.String file)
        Set the image of the actor. If the image is a normal picture, it will be displayed as normal. If it's an animated GIF file then it will be displayed as an animated actor.
      • GifImage

        public GifImage​(GifImage copyFrom)
        Copy the given GifImage. This is faster, and uses less memory, than loading the same GIF multiple times. The current play state (position in the GIF, paused state) is copied from the given GifImage, but after that they can be independently played/paused. The images making up the GIF are shared between the two images, so any modifications to the images will be shared in both GIFs. You can call this constructor on the same source GIF multiple times.
        Parameters:
        copyFrom - The GifImage to copy from.
    • Method Detail

      • getImages

        public java.util.List<greenfoot.GreenfootImage> getImages()
        Get all the images used in the animation
        Returns:
        a list of GreenfootImages, corresponding to each frame.
      • pause

        public void pause()
        Pause the animation.
      • resume

        public void resume()
        Resume the animation.
      • isRunning

        public boolean isRunning()
        Determines whether the animation is running
        Returns:
        true if the animation is running, false otherwise
      • getCurrentImage

        public greenfoot.GreenfootImage getCurrentImage()