Package jwo.utils.gifutils

Classes for handling the creation of GIF image files.

See:
          Description

Class Summary
BitInputStream Allows the reading of 1 to 32 bits at a time, on any bit boundary.
BitOutputStream Allows the writing of 1 to 32 bits at a time, on any bit boundary.
GIFImage GIFImage represents an image as stored in a gif file.
GIFInputStream GIFInputStream provides readXXX() methods useful for reading in the contents of a GIF file.
GIFOutputStream GIFOutputStream provides writeXXX() methods useful for writing out a bitmap image to a GIF file.
ImageQuant Class to quantize an RGB image into fewer colours.
 

Exception Summary
GIFFormatException Indicates that a GIF file is not in the correct format.
LZWException Indicates that an abnormal condition has occured during an operation involving an LZWStringTable
 

Package jwo.utils.gifutils Description

Classes for handling the creation of GIF image files.

Benjamin Norman's GIFUtils package that allows GIF files to be created from Java Images. The original package documentation is included below:

GIFImage is capable of reading all extensions and images in a gif89a file, but only the graphic control extension (used for transparency and time delay) is currently supported for image creation. Multiple images are available (as in an animated .gif). The term 'primary image' is taken to mean the first image in a file.

This package was originally built around GIFEncoder, by Adam Doppelt, which was in turn based on gifsave.c, by Sverre H. Huseby. None of the current incarnation bears much resemblance to these works, however.

GIFImage is currently very alpha-ish, and you may have to do some hacking if you want to take advantage of advanced features like time delays and looping. But it's free, so don't gripe too hard:) If you find a bug with this software, please email Benjamin Norman - bnorman@kent.edu.

Examples

To extract the RGB pixels from a .gif image file:

    GIFInputStream gis = new GIFInputStream(
      new FileInputStream(myFileName) );
    GIFImage gi = new GIFImage(gis);
    int[] rgbPixels = gi.getRGBPixels();
 

To create a .gif file from an array of RGB pixel values:

    int[] rgbPixels = myPixelGenerationMethod();  // get pixels somehow
    GIFImage gi = new GIFImage(rgbPixels, imageWidth);
    GIFOutputStream gos = new GIFOutputStream(
      new FileOutputStream(args[0]) );
    gi.write(gos);
 

To create a GIFImage which makes grey pixels transparent:

    GIFImage gi = new GIFImage(rgbPixels, imageWidth);
    gi.setTransparentColor(Color.grey);
 

To create an animated .gif file using 3 images:

    GIFImage gi = new GIFImage(rgbPixels1, imageWidth);  // first image (0)
    gi.addImage(rgbPixels2, imageWidth);  // second image (1)
    gi.addImage(rgbPixels3, imageWidth);  // third image (2)
    gi.setDelay(50);     // delay in 100th sec - defaults to first image (0)
    gi.setDelay(1, 50);  // second image
    gi.setDelay(2, 50);  // third image
    gi.setIterationCount(0);  // infinite loop
    gi.write(myOutputStream);
 

Related Documentation



Copyright Jo Wood, 1996-2005, last modified, 11th March, 2005