Package 

Class AnimatedGifEncoder

    • Method Summary

      Modifier and Type Method Description
      void setTransparent(int c) Sets the transparent color for the last added frame and any subsequentframes.
      void setRepeat(int iter) Sets the number of times the set of GIF frames should be played.
      void setDelay(int ms) Sets the delay time between each frame, or changes it for subsequent frames(applies to last frame added).
      void setDispose(int code) Sets the GIF frame disposal code for the last added frame and anysubsequent frames.
      boolean addFrame(Bitmap im) Adds next GIF frame.
      boolean finish() Flushes any pending data and closes output file.
      void setFrameRate(float fps) Sets frame rate in frames per second.
      void setQuality(int quality) Sets quality of color quantization (conversion of images to the maximum 256colors allowed by the GIF specification).
      void setSize(int w, int h) Sets the GIF frame size.
      void setPosition(int x, int y) Sets the GIF frame position.
      boolean start(OutputStream os) Initiates GIF file creation on the given stream.
      • Methods inherited from class java.lang.Object

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

      • setTransparent

         void setTransparent(int c)

        Sets the transparent color for the last added frame and any subsequentframes. Since all colors are subject to modification in the quantizationprocess, the color in the final palette for each frame closest to the givencolor becomes the transparent color for that frame. May be set to null toindicate no transparent color.

        Parameters:
        c - Color to be treated as transparent on display.
      • setRepeat

         void setRepeat(int iter)

        Sets the number of times the set of GIF frames should be played. Default is1; 0 means play indefinitely. Must be invoked before the first image isadded.

        Parameters:
        iter - int number of iterations.
      • setDelay

         void setDelay(int ms)

        Sets the delay time between each frame, or changes it for subsequent frames(applies to last frame added).

        Parameters:
        ms - int delay time in milliseconds
      • setDispose

         void setDispose(int code)

        Sets the GIF frame disposal code for the last added frame and anysubsequent frames. Default is 0 if no transparent color has been set,otherwise 2.

        Parameters:
        code - int disposal code.
      • addFrame

         boolean addFrame(Bitmap im)

        Adds next GIF frame. The frame is not written immediately, but is actuallydeferred until the next frame is received so that timing data can beinserted. Invoking finish() flushes all frames. IfsetSize was not invoked, the size of the first image is usedfor all subsequent frames.

        Parameters:
        im - BufferedImage containing frame to write.true if successful.
      • finish

         boolean finish()

        Flushes any pending data and closes output file. If writing to anOutputStream, the stream is not closed.

      • setFrameRate

         void setFrameRate(float fps)

        Sets frame rate in frames per second. Equivalent tosetDelay(1000/fps).

        Parameters:
        fps - float frame rate (frames per second)
      • setQuality

         void setQuality(int quality)

        Sets quality of color quantization (conversion of images to the maximum 256colors allowed by the GIF specification). Lower values (minimum = 1)produce better colors, but slow processing significantly. 10 is thedefault, and produces good color mapping at reasonable speeds. Valuesgreater than 20 do not yield significant improvements in speed.

        Parameters:
        quality - int greater than 0.
      • setSize

         void setSize(int w, int h)

        Sets the GIF frame size. The default size is the size of the first frameadded if this method is not invoked.

        Parameters:
        w - int frame width.
        h - int frame width.
      • setPosition

         void setPosition(int x, int y)

        Sets the GIF frame position. The position is 0,0 by default.Useful for only updating a section of the image

        Parameters:
        x - int frame width.
        y - int frame width.
      • start

         boolean start(OutputStream os)

        Initiates GIF file creation on the given stream. The stream is not closedautomatically.

        Parameters:
        os - OutputStream on which GIF images are written.false if initial write failed.