java的image数组_怎样将Javaimage对象转换成PNG格式字节数组?

** * PngEncoder takes a Java Image object and creates a byte string which can be saved as a PNG file。 * The Image is presumed to use the DirectColorModel。

* * Thanks to Jay Denny at KeyPoint Software * http://www。keypoint。com/ * who let me develop this code on company time。 * * You may contact me with (probably very-much-needed) improvements, * comments, and bug fixes at: * * david@catcode。

com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2。

1 of the License, or (at your option) any later version。 *

* This library 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 * Lesser General Public License for more details。 *

* You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc。

, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * A copy of the GNU LGPL may be found at * http://www。gnu。org/copyleft/lesser。

html, * * @author J。 David Eisenberg * @version 1。4, 31 March 2000 */ import java。awt。*; import java。awt。image。*; import java。

util。*; import java。util。zip。*; import java。io。*; public class PngEncoder extends Object { /** Constant specifying that alpha channel should be encoded。

*/ public static final boolean ENCODE_ALPHA=true; /** Constant specifying that alpha channel should not be encoded。

*/ public static final boolean NO_ALPHA=false; /** Constants for filters */ public static final int FILTER_NONE = 0; public static final int FILTER_SUB = 1; public static final int FILTER_UP = 2; public static final int FILTER_LAST = 2; protected byte[] pngBytes; protected byte[] priorRow; protected byte[] leftBytes; protected Image image; protected int width, height; protected int bytePos, maxPos; protected int hdrPos, dataPos, endPos; protected CRC32 crc = new CRC32(); protected long crcValue; protected boolean encodeAlpha; protected int filter; protected int bytesPERPixel; protected int compressionLevel;。

全部

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值