亚洲欧美第一页_禁久久精品乱码_粉嫩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久久久久久一区二区 | 日韩欧美你懂的| 免费在线观看不卡| 精品国产免费久久| 成人一区二区三区在线观看| 中文字幕亚洲不卡| 欧美日韩午夜影院| 国产麻豆9l精品三级站| 中文av一区特黄| 欧美无砖专区一中文字| 蜜桃av一区二区三区| 欧美经典三级视频一区二区三区| 99精品久久免费看蜜臀剧情介绍| 亚洲国产精品麻豆| 精品国产青草久久久久福利| 99久久99久久精品免费观看| 无吗不卡中文字幕| 久久久蜜桃精品| 欧美综合在线视频| 国产一区三区三区| 亚洲男人的天堂一区二区| 日韩一区二区三区电影| 成人av第一页| 人人狠狠综合久久亚洲| 国产精品久久久久久久久免费桃花 | 国模娜娜一区二区三区| 国产精品白丝在线| 5858s免费视频成人| 暴力调教一区二区三区| 日韩和欧美一区二区三区| 中文字幕第一区| 91精品在线观看入口| 99久久久免费精品国产一区二区| 日本女人一区二区三区| 中文字幕视频一区| 精品动漫一区二区三区在线观看| 色94色欧美sute亚洲线路一久| 精品一区二区三区免费| 亚洲国产精品久久人人爱| 中文幕一区二区三区久久蜜桃| 日韩一区二区在线观看视频| 日本精品一区二区三区高清| 国产一区二区三区四区在线观看| 亚洲综合激情小说| 国产午夜亚洲精品午夜鲁丝片| 色哦色哦哦色天天综合| 国产成人精品网址| 麻豆中文一区二区| 视频一区二区三区入口| 亚洲精品成人悠悠色影视| 久久综合久久综合九色| 欧美一区二区三区男人的天堂| 一本到不卡精品视频在线观看| 国产精品亚洲第一| 国内一区二区在线| 日本中文在线一区| 亚洲成人先锋电影| 亚洲精品高清在线| 最新欧美精品一区二区三区| 久久久久9999亚洲精品| 精品国产精品一区二区夜夜嗨| 欧美日韩精品一区二区三区四区| 色偷偷久久人人79超碰人人澡 | 国产日韩欧美一区二区三区乱码| 日韩欧美你懂的| 日韩女优制服丝袜电影| 在线播放中文字幕一区| 欧美在线观看一二区| 日本高清成人免费播放| 91福利国产精品| 在线观看国产一区二区| 91福利在线看| 欧美伊人久久久久久久久影院| 欧美日韩www| 欧美日韩久久一区二区| 欧美日韩精品欧美日韩精品一| 欧美优质美女网站| 欧美日韩精品欧美日韩精品| 精品视频一区二区三区免费| 欧美图区在线视频| 制服丝袜日韩国产| 日韩亚洲欧美在线| 欧美成人乱码一区二区三区| 日韩欧美中文一区| 26uuu亚洲| 国产精品少妇自拍| 亚洲精品国产第一综合99久久| 亚洲在线观看免费| 石原莉奈一区二区三区在线观看| 五月天丁香久久| 久久国产婷婷国产香蕉| 国产成人在线色| 91网站在线观看视频| 欧美少妇bbb| 精品国产乱码久久久久久浪潮 | 成人av电影免费在线播放| 色婷婷久久综合| 欧美美女一区二区| 欧美大尺度电影在线| 中文字幕免费在线观看视频一区| 亚洲人成小说网站色在线| 午夜精品影院在线观看| 黄一区二区三区| av在线这里只有精品| 欧美午夜精品电影| 久久综合成人精品亚洲另类欧美| ●精品国产综合乱码久久久久| 偷拍一区二区三区| 国产传媒日韩欧美成人| 欧美色视频在线观看| 26uuu精品一区二区在线观看| 中文字幕五月欧美| 久久精品99国产精品日本| 99久久亚洲一区二区三区青草| 91麻豆精品国产91久久久久| 国产色综合久久| 婷婷久久综合九色国产成人 | 国产精品青草综合久久久久99| 亚洲第一av色| 国产suv精品一区二区三区| 欧美羞羞免费网站| 国产欧美一区二区三区沐欲| 亚洲bt欧美bt精品777| 国产91高潮流白浆在线麻豆| 欧美日韩成人在线| 最新日韩av在线| 国内不卡的二区三区中文字幕 | 免费观看在线综合| 99re这里都是精品| 精品日韩一区二区| 亚洲主播在线播放| av一区二区三区在线| 日韩精品一区二区在线| 亚洲图片一区二区| 成人黄色免费短视频| 26uuu国产电影一区二区| 丝袜美腿亚洲一区| 色综合久久六月婷婷中文字幕| 久久免费国产精品| 青青草国产精品亚洲专区无| 色狠狠av一区二区三区| 国产欧美日韩三区| 国内外成人在线| 这里是久久伊人| 亚洲自拍偷拍欧美| 91一区二区在线观看| 国产欧美综合在线观看第十页| 久久精品国产99| 日韩一级片网站| 亚洲国产乱码最新视频| 色久综合一二码| 亚洲男人的天堂在线观看| 9l国产精品久久久久麻豆| 久久精品人人爽人人爽| 国模一区二区三区白浆| 精品久久人人做人人爰| 久久99在线观看| 精品国产人成亚洲区| 精品一区二区三区免费观看 | 国内精品伊人久久久久av一坑| 欧美一区二区三区日韩| 亚洲成人免费在线观看| 欧美日韩国产综合一区二区| 亚洲制服欧美中文字幕中文字幕| 不卡视频在线观看| 亚洲免费成人av| 在线精品视频免费播放| 亚洲国产精品一区二区www| 欧美男生操女生| 日韩国产精品久久久久久亚洲| 欧美精品日日鲁夜夜添| 天天色综合成人网| 欧美一区永久视频免费观看| 日韩av网站在线观看| 欧美一区二区三区免费在线看 | 欧美综合色免费| 五月综合激情网| 在线播放中文字幕一区| 久88久久88久久久| 国产香蕉久久精品综合网| a级高清视频欧美日韩| 一区二区在线看| 91精品国产综合久久香蕉麻豆| 高清不卡在线观看| 蜜桃视频免费观看一区| 欧美一区二区三区视频在线| 美国十次了思思久久精品导航| 欧美成人video| 成人做爰69片免费看网站| 亚洲欧美日韩国产一区二区三区| 欧美亚洲一区三区| 久久99在线观看| 亚洲人成在线播放网站岛国 | 亚洲成人中文在线| 欧美一级国产精品| 成人午夜短视频|