J2ME嶄議GIF侃尖窃
扮寂:2011-04-02
窟匯倖GIF侃尖議窃?辛參受富夕頭彿坿?音俶勣湊謹議png阻
喘隈泌和?
private GIFDecode gifd;
private int ind;
private int gifCount;
private Image frame;
void initGIF() {
gifd = new GIFDecode();
gifd.read(this.getClass().getResourceAsStream("/ar.gif"));//墮秘gif夕頭
ind = 0;
gifCount = gifd.getFrameCount();//資誼屐方
System.out.println("gifCount="+gifCount);
}
void drawProgressBar(Graphics g, int xpos, int ypos, int anchor) {
frame = gifd.getFrame(ind);
ind++;
if (ind >= gifCount) {
ind = 0;
}
g.drawImage(frame, xpos, ypos, anchor);//儉桟紙夕
}
//////////////////////////////////////////////////////////////////////////////////
import java.util.Vector;
import java.io.InputStream;
import javax.microedition.lcdui.Image;
public class GIFDecode {
/**
* File read status: No errors.
*/
public static final int STATUS_OK = 0;
/**
* File read status: Error decoding file (may be partially decoded)
*/
public static final int STATUS_FORMAT_ERROR = 1;
/**
* File read status: Unable to open source.
*/
public static final int STATUS_OPEN_ERROR = 2;
protected InputStream in;
protected int status;
protected int width; // full image width
protected int height; // full image height
protected boolean gctFlag; // global color table used
protected int gctSize; // size of global color table
protected int loopCount = 1; // iterations; 0 = repeat forever
protected int[] gct; // global color table
protected int[] lct; // local color table
protected int[] act; // active color table
protected int bgIndex; // background color index
protected int bgColor; // background color
protected int lastBgColor; // previous bg color
protected int pixelAspect; // pixel aspect ratio
protected boolean lctFlag; // local color table flag
protected boolean interlace; // interlace flag
protected int lctSize; // local color table size
protected int ix, iy, iw, ih; // current image rectangle
protected int lrx, lry, lrw, lrh;
protected Image image; // current frame
protected Image lastImage; // previous frame
protected byte[] block = new byte[256]; // current data block
protected int blockSize = 0; // block size
// last graphic control extension info
protected int dispose = 0;
// 0=no action; 1=leave in place; 2=restore to bg; 3=restore to prev
protected int lastDispose = 0;
protected boolean transparency = false; // use transparent color
protected int delay = 0; // delay in milliseconds
protected int transIndex; // transparent color index
protected static final int MaxStackSize = 4096;
// max decoder pixel stack size
// LZW decoder working arrays
protected short[] prefix;
protected byte[] suffix;
protected byte[] pixelStack;
protected byte[] pixels;
protected Vector frames; // frames read from current file
|