public class AnimGifEncoder extends Object
This class can be used to write an animated GIF file by combining several images. It is loosely based on the Acme GIF encoder.
The characteristics of the generated Gif 89a image are:
An example of how to save an image to GIF is:
import to.etc.sjit.*; // Simple Java Imaging Tools
private void saveGIF(File f, Image i2) throws IOException
{
OutputStream ros = new FileOutputStream(f);
try
{
AnimGifEncoder ge = new AnimGifEncoder(ros);
ge.add(i);
ge.encode();
}
finally
{
try { if(ros != null) ros.close(); } catch {}
}
}
| Modifier and Type | Field and Description |
|---|---|
boolean |
m_no_opt |
| Constructor and Description |
|---|
AnimGifEncoder(OutputStream os)
This constructor creates an empty default codec.
|
AnimGifEncoder(OutputStream os,
boolean interlace)
Creates a codec and specify interlace (not implemented yet).
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(Image ima)
Adds the specified image to the list of images.
|
void |
add(Image ima,
int delay)
Adds the specified image to the list of images.
|
void |
add(Image ima,
int delaytime,
boolean interlace,
int px,
int py)
Adds the specified image to the list of images.
|
void |
encode()
Creates the GIF file from all images added to the encoder.
|
void |
flush()
Releases ALL cached resources.
|
void |
setLoop(boolean loop)
For animated GIF's the default is to LOOP all images in the GIF file.
|
public AnimGifEncoder(OutputStream os)
public AnimGifEncoder(OutputStream os, boolean interlace)
public void setLoop(boolean loop)
For animated GIF's the default is to LOOP all images in the GIF file. This means that after displaying all images in the file the first image is redisplayed ad infinitum.
To prevent the images from looping call setLoop(false) before calling the encode() method.
The current version does not allow the number of repetitions to be specified.
public void flush()
public void add(Image ima, int delaytime, boolean interlace, int px, int py) throws IOException
IOExceptionpublic void add(Image ima) throws IOException
IOExceptionpublic void add(Image ima, int delay) throws IOException
IOExceptionpublic void encode()
throws IOException
IOExceptionCopyright © 2017 etc.to. All rights reserved.