gnu.javax.imageio.gif

Class GIFFile


public class GIFFile
extends Object

GIFFile - reads a GIF file. This class only does the bare minimum work, and returns the data in raw formats (described below). The class is J2ME compatible, and hopefully we can keep it that way without any significant overhead.

Nested Class Summary

static class
GIFFile.GIFException
Generic exception used by GIFFile to report decoding errors.

Constructor Summary

GIFFile(InputStream in)
Loads the file from an input stream, which is not closed.

Method Summary

String
getComment()
Retuns the GIF file comment, or null if none exists.
int
getDuration()
Get duration of the frame for animations.
int
getHeight()
Returns the image height
GIFFile
getImage(int index)
Returns the image file for animated gifs.
int
getNColors()
Returns the # of colors.
byte[]
getRawImage()
Return the image's raw image data.
byte[]
getRawPalette()
Returns the image's palette in raw format (r0,g0,b0,r1,g1,b2..r(Ncolors-1),g(Ncolors-1),b(Ncolors-1))
int
getTransparentIndex()
Returns the index of the transparent color.
int
getWidth()
Returns the (global) width
boolean
hasTransparency()
Returns whether the GIF has transparency.
int
nImages()
Return the number of images in the GIF file
static boolean
readSignature(InputStream in)
Reads a GIF file signature from an inputstream and checks it.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

GIFFile

public GIFFile(InputStream in)
            throws IOException,
                   GIFFile.GIFException
Loads the file from an input stream, which is not closed.
Throws:
IOException - if an I/O error occured.
GIFFile.GIFException - if some file parsing error occured

Method Details

getComment

public String getComment()
Retuns the GIF file comment, or null if none exists.

getDuration

public int getDuration()
Get duration of the frame for animations.

getHeight

public int getHeight()
Returns the image height

getImage

public GIFFile getImage(int index)
Returns the image file for animated gifs.

getNColors

public int getNColors()
Returns the # of colors.

getRawImage

public byte[] getRawImage()
Return the image's raw image data. If the color depth is 1,2 or 4 bits per pixel the pixels are packed and the scanlines padded up to the nearest byte if needed.

getRawPalette

public byte[] getRawPalette()
Returns the image's palette in raw format (r0,g0,b0,r1,g1,b2..r(Ncolors-1),g(Ncolors-1),b(Ncolors-1))

getTransparentIndex

public int getTransparentIndex()
Returns the index of the transparent color.

getWidth

public int getWidth()
Returns the (global) width

hasTransparency

public boolean hasTransparency()
Returns whether the GIF has transparency.

nImages

public int nImages()
Return the number of images in the GIF file

readSignature

public static boolean readSignature(InputStream in)
            throws IOException
Reads a GIF file signature from an inputstream and checks it.
Parameters:
in - - the stream (reads 6 bytes, does not close or reset).
Returns:
true if the signature is a valid GIF signature.
Throws:
IOException - if the signature could not be read.

GIFFile.java -- GIF decoder Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.