public class PNGEncoder
extends java.lang.Object
This code is taken, with permission, from J. David Eisenberg (david@catcode.com), and is distributed under the Artistic License.
Modifier and Type | Field and Description |
---|---|
static int |
FILTER_NONE
Constants for filters
|
static int |
FILTER_SUB |
static int |
FILTER_UP |
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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, 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
|
public static final int FILTER_NONE
public static final int FILTER_SUB
public static final int FILTER_UP
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
public void setImage(java.awt.Image image)
image
- A Java Image object which uses the DirectColorModelImage
,
DirectColorModel
public byte[] pngEncode()
encodeAlpha
- boolean false=no alpha, true=encode alphapublic 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()