|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdeadbeef.Tools.PngEncoder
public class PngEncoder
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
Field Summary | |
---|---|
static boolean |
ENCODE_ALPHA
Constant specifying that alpha channel should be encoded. |
static int |
FILTER_LAST
Constants for filter (LAST) |
static int |
FILTER_NONE
Constants for filter (NONE) |
static int |
FILTER_SUB
Constants for filter (SUB) |
static int |
FILTER_UP
Constants for filter (UP) |
static boolean |
NO_ALPHA
Constant specifying that alpha channel should not be encoded. |
Constructor Summary | |
---|---|
PngEncoder()
Class constructor |
|
PngEncoder(java.awt.Image image)
Class constructor specifying Image to encode, with no alpha channel encoding. |
|
PngEncoder(java.awt.Image image,
boolean encodeAlpha)
Class constructor specifying Image to encode, and whether to encode alpha. |
|
PngEncoder(java.awt.Image image,
boolean encodeAlpha,
int whichFilter)
Class constructor specifying Image to encode, whether to encode alpha, and filter to use. |
|
PngEncoder(java.awt.Image image,
boolean encodeAlpha,
int whichFilter,
int compLevel)
Class constructor specifying Image source to encode, whether to encode alpha, filter to use, and compression level. |
Method Summary | |
---|---|
int |
getCompressionLevel()
Retrieve compression level |
boolean |
getEncodeAlpha()
Retrieve alpha encoding status. |
int |
getFilter()
Retrieve filtering scheme |
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 |
setCompressionLevel(int level)
Set the compression level to use |
void |
setEncodeAlpha(boolean encodeAlpha)
Set the alpha encoding on or off. |
void |
setFilter(int whichFilter)
Set the filter to use |
void |
setImage(java.awt.Image image)
Set the image to be encoded |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final boolean ENCODE_ALPHA
public static final boolean NO_ALPHA
public static final int FILTER_NONE
public static final int FILTER_SUB
public static final int FILTER_UP
public static final int FILTER_LAST
Constructor Detail |
---|
public PngEncoder()
public PngEncoder(java.awt.Image image)
image
- A Java Image object which uses the DirectColorModelImage
public PngEncoder(java.awt.Image image, boolean encodeAlpha)
image
- A Java Image object which uses the DirectColorModelencodeAlpha
- Encode the alpha channel? false=no; true=yesImage
public PngEncoder(java.awt.Image image, boolean encodeAlpha, int whichFilter)
image
- A Java Image object which uses the DirectColorModelencodeAlpha
- Encode the alpha channel? false=no; true=yeswhichFilter
- 0=none, 1=sub, 2=upImage
public PngEncoder(java.awt.Image image, boolean encodeAlpha, int whichFilter, int compLevel)
image
- A Java Image objectencodeAlpha
- Encode the alpha channel? false=no; true=yeswhichFilter
- 0=none, 1=sub, 2=upcompLevel
- 0..9Image
Method Detail |
---|
public void setImage(java.awt.Image image)
image
- A Java Image object which uses the DirectColorModelImage
,
DirectColorModel
public byte[] pngEncode(boolean encodeAlpha)
encodeAlpha
- boolean false=no alpha, true=encode alpha
public byte[] pngEncode()
public void setEncodeAlpha(boolean encodeAlpha)
encodeAlpha
- false=no, true=yespublic boolean getEncodeAlpha()
public void setFilter(int whichFilter)
whichFilter
- from constant listpublic int getFilter()
public void setCompressionLevel(int level)
level
- 0 through 9public int getCompressionLevel()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |