public class GifDecoder extends Object
Example:
GifDecoder d = new GifDecoder();
d.read("sample.gif");
int n = d.getFrameCount();
for (int i = 0; i < n; i++) {
BufferedImage frame = d.getFrame(i); // frame i
int t = d.getDelay(i); // display duration of frame in milliseconds
// do something with frame
}
No copyright asserted on the source code of this class. May be used for any
purpose, however, refer to the Unisys LZW patent for any additional
restrictions. Please forward any corrections to kweiner@fmsware.com.| Modifier and Type | Field and Description |
|---|---|
static int |
STATUS_FORMAT_ERROR
File read status: Error decoding file (may be partially decoded)
|
static int |
STATUS_OK
File read status: No errors.
|
static int |
STATUS_OPEN_ERROR
File read status: Unable to open source.
|
| Constructor and Description |
|---|
GifDecoder() |
| Modifier and Type | Method and Description |
|---|---|
int |
getDelay(int n)
Gets display duration for specified frame.
|
BufferedImage |
getFrame(int n)
Gets the image contents of frame n.
|
int |
getFrameCount()
Gets the number of frames read from file.
|
Dimension |
getFrameSize()
Gets image size.
|
BufferedImage |
getImage()
Gets the first (or only) image read.
|
int |
getLoopCount()
Gets the "Netscape" iteration count, if any.
|
int |
read(BufferedInputStream is)
Reads GIF image from stream
|
int |
read(InputStream is)
Reads GIF image from stream
|
int |
read(String name)
Reads GIF file from specified file/URL source (URL assumed if name contains
":/" or "file:")
|
public static final int STATUS_OK
public static final int STATUS_FORMAT_ERROR
public static final int STATUS_OPEN_ERROR
public int getDelay(int n)
n - int index of framepublic int getFrameCount()
public BufferedImage getImage()
public int getLoopCount()
public BufferedImage getFrame(int n)
n - : frame numberpublic Dimension getFrameSize()
public int read(BufferedInputStream is)
is - : BufferedInputStream containing GIF file.public int read(InputStream is)
is - : InputStream containing GIF file.public int read(String name)
name - : String containing sourceProcessing Library GifAnimation by Patrick Meister, Jerome Saint-Clair. ${library.copyright}