资源简介
java图片压缩处理 支持gif动态图的处理,绝对真实,项目中亲自使用

代码片段和文件信息
package com.molfun.my.imgutils2;
import java.io.*;
import java.awt.*;
import java.awt.image.*;
/**
* Class AnimatedGifEncoder - Encodes a GIF file consisting of one or
* more frames.
*
* Example:
* AnimatedGifEncoder e = new AnimatedGifEncoder();
* e.start(outputFileName);
* e.setDelay(1000); // 1 frame per sec
* e.addframe(image1);
* e.addframe(image2);
* e.finish();
*
* No copyright asserted on the source code of this class. May be used
* for any purpose however refer to the Unisys LZW patent for restrictions
* on use of the associated LZWEncoder class. Please forward any corrections
* to questions at fmsware.com.
*
* @author Kevin Weiner FM Software
* @version 1.03 November 2003
*
*/
public class AnimatedGifEncoder {
protected int width; // image size
protected int height;
protected Color transparent = null; // transparent color if given
protected int transIndex; // transparent index in color table
protected int repeat = -1; // no repeat
protected int delay = 0; // frame delay (hundredths)
protected boolean started = false; // ready to output frames
protected OutputStream out;
protected BufferedImage image; // current frame
protected byte[] pixels; // BGR byte array from frame
protected byte[] indexedPixels; // converted frame indexed to palette
protected int colorDepth; // number of bit planes
protected byte[] colorTab; // RGB palette
protected boolean[] usedEntry = new boolean[256]; // active palette entries
protected int palSize = 7; // color table size (bits-1)
protected int dispose = -1; // disposal code (-1 = use default)
protected boolean closeStream = false; // close stream when finished
protected boolean firstframe = true;
protected boolean sizeSet = false; // if false get size from first frame
protected int sample = 10; // default sample interval for quantizer
/**
* Sets the delay time between each frame or changes it
* for subsequent frames (applies to last frame added).
*
* @param ms int delay time in milliseconds
*/
public void setDelay(int ms) {
delay = Math.round(ms / 10.0f);
}
/**
* Sets the GIF frame disposal code for the last added frame
* and any subsequent frames. Default is 0 if no transparent
* color has been set otherwise 2.
* @param code int disposal code.
*/
public void setDispose(int code) {
if (code >= 0) {
dispose = code;
}
}
/**
* Sets the number of times the set of GIF frames
* should be played. Default is 1; 0 means play
* indefinitely. Must be invoked before the first
* image is added.
*
* @param iter int number of iterations.
* @return
*/
public void setRepeat(int iter) {
if (iter >= 0) {
repeat = iter;
}
}
/**
* Sets the transparent color for the last added frame
* and any subsequent frames.
* Since all colors are subject to modification
* in the quantizatio
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 12947 2009-12-28 16:28 imgutils2\AnimatedGifEncoder.java
文件 18425 2009-12-28 16:28 imgutils2\GifDecoder.java
文件 8272 2009-12-28 16:28 imgutils2\ImageSpek.java
文件 8030 2009-12-28 16:28 imgutils2\LZWEncoder.java
文件 13212 2009-12-28 16:28 imgutils2\NeuQuant.java
文件 406 2009-12-28 16:28 imgutils2\test.java
文件 5064 2009-12-28 16:28 imgutils2\UploadUtil.java
目录 0 2009-12-28 15:47 imgutils2
----------- --------- ---------- ----- ----
66356 8
- 上一篇:java代码生成器内含模板
- 下一篇:医院门诊管理系统
相关资源
- java串口通信全套完整代码-导入eclip
- jsonarray所必需的6个jar包.rar
- 三角网构TIN生成算法,Java语言实现
- java代码编写将excel数据导入到mysql数据
- Java写的cmm词法分析器源代码及javacc学
- JAVA JSP公司财务管理系统 源代码 论文
- JSP+MYSQL旅行社管理信息系统
- 推荐算法的JAVA实现
- 基于Java的酒店管理系统源码(毕业设
- java-图片识别 图片比较
- android毕业设计
- java23种设计模式+23个实例demo
- java Socket发送/接受报文
- JAVA828436
- java界面美化 提供多套皮肤直接使用
- 在线聊天系统(java代码)
- 基于Java的图书管理系统807185
- java中实现将页面数据导入Excel中
- java 企业销售管理系统
- java做的聊天系统(包括正规课程设计
- Java编写的qq聊天室
- 商店商品管理系统 JAVA写的 有界面
- JAVA开发聊天室程序
- 在linux系统下用java执行系统命令实例
- java期末考试试题两套(答案) 选择(
- JAVA3D编程示例(建模、交互)
- Java 文件加密传输
- java做的房产管理系统
- 基于jsp的bbs论坛 非常详细
- [免费]java实现有障碍物的贪吃蛇游戏
评论
共有 条评论