亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? gifdecoder.java

?? 個人Blog java編寫的Blog可以直接使用!
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
package com.liusoft.util.gif;
import java.net.*;
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.image.*;

/**
 * Class GifDecoder - Decodes a GIF file into one or more frames.
 * <br><pre>
 * 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
 *    }
 * </pre>
 * 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.
 *
 * @author Kevin Weiner, FM Software; LZW decoder adapted from John Cristy's ImageMagick.
 * @version 1.03 November 2003
 *
 */

public class GifDecoder {

	/**
	 * 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 BufferedInputStream 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 Rectangle lastRect; // last image rect
	protected BufferedImage image; // current frame
	protected BufferedImage 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 ArrayList frames; // frames read from current file
	protected int frameCount;

	static class GifFrame {
		public GifFrame(BufferedImage im, int del) {
			image = im;
			delay = del;
		}
		public BufferedImage image;
		public int delay;
	}

	/**
	 * Gets display duration for specified frame.
	 *
	 * @param n int index of frame
	 * @return delay in milliseconds
	 */
	public int getDelay(int n) {
		//
		delay = -1;
		if ((n >= 0) && (n < frameCount)) {
			delay = ((GifFrame) frames.get(n)).delay;
		}
		return delay;
	}

	/**
	 * Gets the number of frames read from file.
	 * @return frame count
	 */
	public int getFrameCount() {
		return frameCount;
	}

	/**
	 * Gets the first (or only) image read.
	 *
	 * @return BufferedImage containing first frame, or null if none.
	 */
	public BufferedImage getImage() {
		return getFrame(0);
	}

	/**
	 * Gets the "Netscape" iteration count, if any.
	 * A count of 0 means repeat indefinitiely.
	 *
	 * @return iteration count if one was specified, else 1.
	 */
	public int getLoopCount() {
		return loopCount;
	}

	/**
	 * Creates new frame image from current data (and previous
	 * frames as specified by their disposition codes).
	 */
	protected void setPixels() {
		// expose destination image's pixels as int array
		int[] dest =
			((DataBufferInt) image.getRaster().getDataBuffer()).getData();

		// fill in starting image contents based on last image's dispose code
		if (lastDispose > 0) {
			if (lastDispose == 3) {
				// use image before last
				int n = frameCount - 2;
				if (n > 0) {
					lastImage = getFrame(n - 1);
				} else {
					lastImage = null;
				}
			}

			if (lastImage != null) {
				int[] prev =
					((DataBufferInt) lastImage.getRaster().getDataBuffer()).getData();
				System.arraycopy(prev, 0, dest, 0, width * height);
				// copy pixels

				if (lastDispose == 2) {
					// fill last image rect area with background color
					Graphics2D g = image.createGraphics();
					Color c = null;
					if (transparency) {
						c = new Color(0, 0, 0, 0); 	// assume background is transparent
					} else {
						c = new Color(lastBgColor); // use given background color
					}
					g.setColor(c);
					g.setComposite(AlphaComposite.Src); // replace area
					g.fill(lastRect);
					g.dispose();
				}
			}
		}

		// copy each source line to the appropriate place in the destination
		int pass = 1;
		int inc = 8;
		int iline = 0;
		for (int i = 0; i < ih; i++) {
			int line = i;
			if (interlace) {
				if (iline >= ih) {
					pass++;
					switch (pass) {
						case 2 :
							iline = 4;
							break;
						case 3 :
							iline = 2;
							inc = 4;
							break;
						case 4 :
							iline = 1;
							inc = 2;
					}
				}
				line = iline;
				iline += inc;
			}
			line += iy;
			if (line < height) {
				int k = line * width;
				int dx = k + ix; // start of line in dest
				int dlim = dx + iw; // end of dest line
				if ((k + width) < dlim) {
					dlim = k + width; // past dest edge
				}
				int sx = i * iw; // start of line in source
				while (dx < dlim) {
					// map color and insert in destination
					int index = ((int) pixels[sx++]) & 0xff;
					int c = act[index];
					if (c != 0) {
						dest[dx] = c;
					}
					dx++;
				}
			}
		}
	}

	/**
	 * Gets the image contents of frame n.
	 *
	 * @return BufferedImage representation of frame, or null if n is invalid.
	 */
	public BufferedImage getFrame(int n) {
		BufferedImage im = null;
		if ((n >= 0) && (n < frameCount)) {
			im = ((GifFrame) frames.get(n)).image;
		}
		return im;
	}

	/**
	 * Gets image size.
	 *
	 * @return GIF image dimensions
	 */
	public Dimension getFrameSize() {
		return new Dimension(width, height);
	}

	/**
	 * Reads GIF image from stream
	 *
	 * @param BufferedInputStream containing GIF file.
	 * @return read status code (0 = no errors)
	 */
	public int read(BufferedInputStream is) {
		init();
		if (is != null) {
			in = is;
			readHeader();
			if (!err()) {
				readContents();
				if (frameCount < 0) {
					status = STATUS_FORMAT_ERROR;
				}
			}
		} else {
			status = STATUS_OPEN_ERROR;
		}
		try {
			is.close();
		} catch (IOException e) {
		}
		return status;
	}

	/**
	 * Reads GIF image from stream
	 *
	 * @param InputStream containing GIF file.
	 * @return read status code (0 = no errors)
	 */
	public int read(InputStream is) {
		init();
		if (is != null) {
			if (!(is instanceof BufferedInputStream))
				is = new BufferedInputStream(is);
			in = (BufferedInputStream) is;
			readHeader();
			if (!err()) {
				readContents();
				if (frameCount < 0) {
					status = STATUS_FORMAT_ERROR;
				}
			}
		} else {
			status = STATUS_OPEN_ERROR;
		}
		try {
			is.close();
		} catch (IOException e) {
		}
		return status;
	}

	/**
	 * Reads GIF file from specified file/URL source  
	 * (URL assumed if name contains ":/" or "file:")
	 *
	 * @param name String containing source
	 * @return read status code (0 = no errors)
	 */
	public int read(String name) {
		status = STATUS_OK;
		try {
			name = name.trim().toLowerCase();
			if ((name.indexOf("file:") >= 0) ||
				(name.indexOf(":/") > 0)) {
				URL url = new URL(name);
				in = new BufferedInputStream(url.openStream());
			} else {
				in = new BufferedInputStream(new FileInputStream(name));
			}
			status = read(in);
		} catch (IOException e) {
			status = STATUS_OPEN_ERROR;
		}

		return status;
	}

	/**
	 * Decodes LZW image data into pixel array.
	 * Adapted from John Cristy's ImageMagick.
	 */
	protected void decodeImageData() {
		int NullCode = -1;
		int npix = iw * ih;
		int available, 
			clear,
			code_mask,
			code_size,
			end_of_information,
			in_code,
			old_code,
			bits,
			code,
			count,
			i,
			datum,
			data_size,
			first,
			top,
			bi,
			pi;

		if ((pixels == null) || (pixels.length < npix)) {
			pixels = new byte[npix]; // allocate new pixel array
		}
		if (prefix == null) prefix = new short[MaxStackSize];
		if (suffix == null) suffix = new byte[MaxStackSize];
		if (pixelStack == null) pixelStack = new byte[MaxStackSize + 1];

		//  Initialize GIF data stream decoder.

		data_size = read();
		clear = 1 << data_size;
		end_of_information = clear + 1;
		available = clear + 2;
		old_code = NullCode;
		code_size = data_size + 1;
		code_mask = (1 << code_size) - 1;
		for (code = 0; code < clear; code++) {
			prefix[code] = 0;
			suffix[code] = (byte) code;
		}

		//  Decode GIF pixel stream.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产在线精品一区二区不卡了 | 91精品一区二区三区在线观看| 久久亚洲一级片| 蜜芽一区二区三区| 91视频www| 亚洲第一久久影院| 日韩一二三区不卡| 国产精品91一区二区| 亚洲欧美成人一区二区三区| 一本大道av伊人久久综合| 亚洲动漫第一页| 国产亚洲一二三区| 欧美理论电影在线| 国产69精品久久99不卡| 亚洲欧美日韩系列| 亚洲3atv精品一区二区三区| 日本不卡在线视频| 亚洲午夜私人影院| 免费观看在线色综合| 国产一区二区三区高清播放| 不卡电影一区二区三区| 日产精品久久久久久久性色| 日韩高清一区二区| 成人一区二区三区中文字幕| 日韩电影免费在线观看网站| 美女在线视频一区| 成人黄色国产精品网站大全在线免费观看| 精品国产91九色蝌蚪| 99精品视频在线观看| 国产麻豆成人精品| 色噜噜偷拍精品综合在线| 国产99一区视频免费| 91福利国产精品| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 亚洲一区二区三区在线| 国产视频一区二区在线观看| 成人欧美一区二区三区白人| 精品日产卡一卡二卡麻豆| 91麻豆精品国产91久久久资源速度 | 欧美日韩国产成人在线91| 色综合天天性综合| 高清av一区二区| 欧美日韩在线免费视频| 91麻豆产精品久久久久久 | 国产一级精品在线| 色婷婷国产精品久久包臀| 日韩女同互慰一区二区| 精品国产乱码91久久久久久网站| 亚洲欧洲美洲综合色网| 韩国在线一区二区| 国产成人亚洲精品狼色在线 | 亚洲人成在线播放网站岛国| 免费成人性网站| 欧美婷婷六月丁香综合色| 欧美日韩精品一区二区天天拍小说| 国产亚洲欧美日韩俺去了| 丝袜诱惑制服诱惑色一区在线观看| 日韩黄色免费网站| 在线欧美小视频| 欧美一级久久久| 亚洲大片一区二区三区| 色网站国产精品| 亚洲天堂av老司机| 五月婷婷综合网| 蜜臀久久99精品久久久画质超高清| 91一区一区三区| 亚洲欧洲国产日韩| jlzzjlzz欧美大全| 在线看日本不卡| 亚洲欧美日韩一区| 色悠悠亚洲一区二区| 中文字幕一区二区三| 不卡的av电影| 亚洲视频在线一区| 色国产精品一区在线观看| 亚洲精品国产a久久久久久| 日本午夜精品一区二区三区电影| 欧美日韩国产天堂| 日本欧美在线看| 精品国产自在久精品国产| 国产美女在线精品| 国产欧美日韩在线视频| 亚洲成人精品在线观看| 欧美日韩黄色影视| 久久国产三级精品| 欧美又粗又大又爽| 亚洲成人动漫在线免费观看| 欧美精品在线视频| 精品一区二区三区久久久| 在线欧美一区二区| 蜜桃精品视频在线观看| 欧美va亚洲va| 成人午夜电影网站| 一区二区国产盗摄色噜噜| 国产伦精一区二区三区| 国产精品美女久久福利网站| 日韩av一区二区三区| 精品蜜桃在线看| caoporen国产精品视频| 亚洲一区二区三区视频在线 | 色综合激情久久| 美女网站在线免费欧美精品| 久久久精品国产99久久精品芒果 | 中文字幕欧美激情| 国内国产精品久久| 亚洲男人的天堂在线aⅴ视频| 在线看日韩精品电影| 精品综合免费视频观看| 一区在线播放视频| 欧美v日韩v国产v| 色偷偷88欧美精品久久久| 老司机免费视频一区二区| 中文字幕一区二区视频| 欧美sm极限捆绑bd| 色噜噜狠狠色综合中国| 国精产品一区一区三区mba视频| 国产精品短视频| 97精品电影院| 国产一区在线观看视频| 亚洲国产日韩精品| 国产精品久久久久影视| 日韩欧美国产小视频| 欧洲国内综合视频| 不卡一区中文字幕| 国产成人免费网站| 婷婷夜色潮精品综合在线| 国产精品久久久久影院| 久久亚洲一区二区三区明星换脸| 欧美亚洲国产一区二区三区| 国产精品2024| 久久成人18免费观看| 三级欧美韩日大片在线看| 亚洲精品乱码久久久久久日本蜜臀| 久久久久久一级片| 欧美大胆一级视频| 日韩一区二区精品| 91精品免费观看| 欧美日本在线观看| 在线免费不卡电影| 在线观看av一区| 一本大道久久精品懂色aⅴ| 99久久免费视频.com| 成人免费精品视频| 成人精品gif动图一区| 国产精品性做久久久久久| 久久精品国产亚洲高清剧情介绍| 午夜精品久久久久久久 | 久久婷婷久久一区二区三区| 6080日韩午夜伦伦午夜伦| 欧美精选在线播放| 欧美老人xxxx18| 欧美丰满高潮xxxx喷水动漫| 欧美日韩你懂得| 日韩午夜激情视频| 精品三级在线看| 国产欧美日韩精品一区| 久久久精品蜜桃| 国产精品福利一区二区三区| 国产精品二区一区二区aⅴ污介绍| 国产精品日产欧美久久久久| 国产精品美女视频| 亚洲精品国产高清久久伦理二区| 亚洲精品五月天| 日韩av一区二区三区| 精品午夜一区二区三区在线观看| 久久精品国产成人一区二区三区 | 欧美日韩www| 91精品欧美福利在线观看| 日韩免费高清av| 久久久综合九色合综国产精品| 久久久久久夜精品精品免费| 国产精品电影院| 午夜私人影院久久久久| 国产原创一区二区| 99久久国产综合精品女不卡| 欧美日韩中文字幕一区二区| 91精品婷婷国产综合久久性色| 久久午夜羞羞影院免费观看| 国产精品区一区二区三区| 亚洲蜜臀av乱码久久精品蜜桃| 日韩黄色片在线观看| 国产成人亚洲综合色影视| 欧美在线你懂的| 国产欧美日韩在线| 亚洲小少妇裸体bbw| 国产精品99久| 欧美日韩不卡视频| 欧美国产日本韩| 日日夜夜免费精品视频| 粉嫩av亚洲一区二区图片| 久久午夜免费电影| 亚洲永久免费av| 国产精品一区二区在线播放| 欧美亚一区二区| 国产欧美日韩一区二区三区在线观看| 夜夜亚洲天天久久| 国产精品一区二区免费不卡| 欧美猛男超大videosgay| 国产精品视频一区二区三区不卡| 日韩精品国产欧美|