|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.keypoint.PngEncoder | +--com.keypoint.PngEncoderB
PngEncoderB takes a Java BufferedImage object and creates a byte string which can be saved as a PNG file. The encoder will accept BufferedImages with eight-bit samples or 4-byte ARGB samples.
There is also code to handle 4-byte samples returned as one int per pixel, but that has not been tested.
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
Field Summary | |
protected java.awt.image.BufferedImage |
image
|
protected int |
tType
|
protected java.awt.image.WritableRaster |
wRaster
|
Fields inherited from class com.keypoint.PngEncoder |
bytePos, bytesPerPixel, compressionLevel, crc, crcValue, ENCODE_ALPHA, encodeAlpha, filter, FILTER_LAST, FILTER_NONE, FILTER_SUB, FILTER_UP, height, IDAT, IEND, IHDR, leftBytes, maxPos, NO_ALPHA, pngBytes, priorRow, width |
Constructor Summary | |
PngEncoderB()
Class constructor |
|
PngEncoderB(java.awt.image.BufferedImage image)
Class constructor specifying BufferedImage to encode, with no alpha channel encoding. |
|
PngEncoderB(java.awt.image.BufferedImage image,
boolean encodeAlpha)
Class constructor specifying BufferedImage to encode, and whether to encode alpha. |
|
PngEncoderB(java.awt.image.BufferedImage image,
boolean encodeAlpha,
int whichFilter)
Class constructor specifying BufferedImage to encode, whether to encode alpha, and filter to use. |
|
PngEncoderB(java.awt.image.BufferedImage image,
boolean encodeAlpha,
int whichFilter,
int compLevel)
Class constructor specifying BufferedImage source to encode, whether to encode alpha, filter to use, and compression level |
Method Summary | |
protected boolean |
establishStorageInfo()
Get and set variables that determine how picture is stored. |
byte[] |
pngEncode()
Creates an array of bytes that is the PNG equivalent of the current image. |
byte[] |
pngEncode(boolean encodeAlpha)
Creates an array of bytes that is the PNG equivalent of the current image, specifying whether to encode alpha or not. |
void |
setImage(java.awt.image.BufferedImage image)
Set the BufferedImage to be encoded |
protected void |
writeHeader()
Write a PNG "IHDR" chunk into the pngBytes array. |
protected boolean |
writeImageData()
Write the image data into the pngBytes array. |
protected void |
writePalette(java.awt.image.IndexColorModel icm)
|
Methods inherited from class com.keypoint.PngEncoder |
filterSub, filterUp, getCompressionLevel, getEncodeAlpha, getFilter, resizeByteArray, setCompressionLevel, setEncodeAlpha, setFilter, setImage, writeByte, writeBytes, writeBytes, writeEnd, writeInt2, writeInt4 |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.awt.image.BufferedImage image
protected java.awt.image.WritableRaster wRaster
protected int tType
Constructor Detail |
public PngEncoderB()
public PngEncoderB(java.awt.image.BufferedImage image)
image
- A Java BufferedImage objectpublic PngEncoderB(java.awt.image.BufferedImage image, boolean encodeAlpha)
image
- A Java BufferedImage objectencodeAlpha
- Encode the alpha channel? false=no; true=yespublic PngEncoderB(java.awt.image.BufferedImage image, boolean encodeAlpha, int whichFilter)
image
- A Java BufferedImage objectencodeAlpha
- Encode the alpha channel? false=no; true=yeswhichFilter
- 0=none, 1=sub, 2=uppublic PngEncoderB(java.awt.image.BufferedImage image, boolean encodeAlpha, int whichFilter, int compLevel)
image
- A Java BufferedImage objectencodeAlpha
- Encode the alpha channel? false=no; true=yeswhichFilter
- 0=none, 1=sub, 2=upcompLevel
- 0..9Method Detail |
public void setImage(java.awt.image.BufferedImage image)
public byte[] pngEncode(boolean encodeAlpha)
pngEncode
in class PngEncoder
encodeAlpha
- boolean false=no alpha, true=encode alpha
public byte[] pngEncode()
pngEncode
in class PngEncoder
protected boolean establishStorageInfo()
protected void writeHeader()
writeHeader
in class PngEncoder
protected void writePalette(java.awt.image.IndexColorModel icm)
protected boolean writeImageData()
writeImageData
in class PngEncoder
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |