nextapp.echoservlet.image
Class PngEncoder
java.lang.Object
nextapp.echoservlet.image.PngEncoder
- public class PngEncoder
- extends java.lang.Object
Encodes a java.awt.Image into PNG format.
For more information on the PNG specification, see the W3C PNG page at
http://www.w3.org/TR/REC-png.html.
Nested Class Summary |
static interface |
PngEncoder.Filter
An interface for PNG filters. |
Constructor Summary |
PngEncoder(java.awt.Image image,
boolean encodeAlpha,
PngEncoder.Filter filter,
int compressionLevel)
Creates a PNG encoder for an image. |
Method Summary |
void |
encode(java.io.OutputStream out)
Encodes the image. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SUB_FILTER
public static final PngEncoder.Filter SUB_FILTER
UP_FILTER
public static final PngEncoder.Filter UP_FILTER
AVERAGE_FILTER
public static final PngEncoder.Filter AVERAGE_FILTER
PAETH_FILTER
public static final PngEncoder.Filter PAETH_FILTER
PngEncoder
public PngEncoder(java.awt.Image image,
boolean encodeAlpha,
PngEncoder.Filter filter,
int compressionLevel)
- Creates a PNG encoder for an image.
- Parameters:
image
- The image to be encoded.encodeAlpha
- True if the image's alpha channel should be encoded.filter
- The filter to be applied to the image data, one of the
following values:
- SUB_FILTER
- UP_FILTER
- AVERAGE_FILTER
- PAETH_FILTER
If a null value is specified, no filtering will be performed.compressionLevel
- The deflater compression level that will be used
for compressing the image data. Valid values range from 0 to 9.
Higher values result in smaller files and therefore decrease
network traffic, but require more CPU time to encode. The normal
compromise value is 3.
encode
public void encode(java.io.OutputStream out)
throws java.io.IOException
- Encodes the image.
- Parameters:
out
- An OutputStream to which the encoded image will be
written.
- Throws:
java.io.IOException
- if a problem is encountered writing the output.