Class GifDecoder


  • public final class GifDecoder
    extends java.lang.Object

    A decoder capable of processing a GIF data stream to render the graphics contained in it. This implementation follows the official GIF specification.

    Example usage:

     final GifImage gifImage = GifDecoder.read(int[] data);
     final int width = gifImage.getWidth();
     final int height = gifImage.getHeight();
     final int frameCount = gifImage.getFrameCount();
     for (int i = 0; i < frameCount; i++) {
            final BufferedImage image = gifImage.getFrame(i);
            final int delay = gif.getDelay(i);
     }
     
    Author:
    Dhyan Blum
    • Constructor Detail

      • GifDecoder

        public GifDecoder()
    • Method Detail

      • read

        public static final GifDecoder.GifImage read​(byte[] in)
                                              throws java.io.IOException
        Parameters:
        in - Raw image data as a byte[] array
        Returns:
        A GifImage object exposing the properties of the GIF image.
        Throws:
        java.io.IOException - If the image violates the GIF specification or is truncated.
      • read

        public static final GifDecoder.GifImage read​(java.io.InputStream is)
                                              throws java.io.IOException
        Parameters:
        is - Image data as input stream. This method will read from the input stream's current position. It will not reset the position before reading and won't reset or close the stream afterwards. Call these methods before and after calling this method as needed.
        Returns:
        A GifImage object exposing the properties of the GIF image.
        Throws:
        java.io.IOException - If an I/O error occurs, the image violates the GIF specification or the GIF is truncated.