資源簡介
代碼片段和文件信息
package?com.keypoint;
import?java.awt.Image;
import?java.awt.image.ImageObserver;
import?java.awt.image.PixelGrabber;
import?java.io.ByteArrayOutputStream;
import?java.io.IOException;
import?java.util.zip.CRC32;
import?java.util.zip.Deflater;
import?java.util.zip.DeflaterOutputStream;
/**
?*?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.?51?Franklin?Street?Fifth?Floor?Boston?MA??02110-1301
?*?USA.?A?copy?of?the?GNU?LGPL?may?be?found?at
?*?http://www.gnu.org/copyleft/lesser.html
?*
?*?@author?J.?David?Eisenberg
?*?@version?1.5?19?Oct?2003
?*
?*?CHANGES:
?*?--------
?*?19-Nov-2002?:?CODING?style?CHANGES?ONLY?(by?David?Gilbert?for?object
?*???????????????Refinery?Limited);
?*?19-Sep-2003?:?Fix?for?platforms?using?EBCDIC?(contributed?by?Paulo?Soares);
?*?19-Oct-2003?:?Change?private?fields?to?protected?fields?so?that
?*???????????????PngEncoderB?can?inherit?them?(JDE)
?*???????????????Fixed?bug?with?calculation?of?nRows
?*/
public?class?PngEncoder?{
????/**?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?filter?(NONE).?*/
????public?static?final?int?FILTER_NONE?=?0;
????/**?Constants?for?filter?(SUB).?*/
????public?static?final?int?FILTER_SUB?=?1;
????/**?Constants?for?filter?(UP).?*/
????public?static?final?int?FILTER_UP?=?2;
????/**?Constants?for?filter?(LAST).?*/
????public?static?final?int?FILTER_LAST?=?2;
????/**?IHDR?tag.?*/
????protected?static?final?byte[]?IHDR?=?{73?72?68?82};
????/**?IDAT?tag.?*/
????protected?static?final?byte[]?IDAT?=?{73?68?65?84};
????/**?IEND?tag.?*/
????protected?static?final?byte[]?IEND?=?{73?69?78?68};
????protected?static?final?byte[]?PHYS?=?{(byte)‘p‘?(byte)‘H‘?(byte)‘Y‘?(byte)‘s‘};
???
評論
共有 條評論