public interface JPEGImageEncoder
OutputStream that is the destination of the encoded
JPEG stream.
The JPEGImageEncoder interface can encode image data into interchange,
and abbreviated JPEG data streams that are written to the
OutputStream provided to the encoder.
Note that the classes in the com.sun.image.codec.jpeg package are not part of the core Java APIs. They are a part of Sun's JDK and JRE distributions. Although other licensees may choose to distribute these classes, developers cannot depend on their availability in non-Sun implementations. We expect that equivalent functionality will eventually be available in a core API or standard extension.
JPEGCodec,
JPEGEncodeParam,
Raster,
BufferedImage,
OutputStream| 限定符和类型 | 方法和说明 |
|---|---|
void |
encode(BufferedImage bi)
Encode a BufferedImage as a JPEG data stream.
|
void |
encode(BufferedImage bi,
JPEGEncodeParam jep)
Encode a BufferedImage as a JPEG data stream.
|
void |
encode(Raster ras)
Encode a Raster as a JPEG data stream.
|
void |
encode(Raster ras,
JPEGEncodeParam jep)
Encode a Raster as a JPEG data stream.
|
int |
getDefaultColorId(ColorModel cm)
Returns the 'default' encoded COLOR_ID for a given ColorModel.
|
JPEGEncodeParam |
getDefaultJPEGEncodeParam(BufferedImage bi)
This is a factory method for creating JPEGEncodeParam objects.
|
JPEGEncodeParam |
getDefaultJPEGEncodeParam(int numBands,
int colorID)
This is a factory method for creating JPEGEncodeParam objects.
|
JPEGEncodeParam |
getDefaultJPEGEncodeParam(JPEGDecodeParam jdp)
This is a factory method for creating a JPEGEncodeParam from a
JPEGDecodeParam.
|
JPEGEncodeParam |
getDefaultJPEGEncodeParam(Raster ras,
int colorID)
This is a factory method for creating JPEGEncodeParam objects.
|
JPEGEncodeParam |
getJPEGEncodeParam()
This returns a copy of the current JPEGEncodeParam object, if
you want changes to affect the encoding process you must 'set'
it back into the encoder (either through setJPEGEncodeParam or
by providing the modified param object in the call to encode.
|
OutputStream |
getOutputStream()
Return the stream the Encoder is currenlt associated with.
|
void |
setJPEGEncodeParam(JPEGEncodeParam jep)
Set the JPEGEncodeParam object that is to be used for future
encoding operations.
|
OutputStream getOutputStream()
void setJPEGEncodeParam(JPEGEncodeParam jep)
jep - The JPEGEncodeParam object to use for future encodings.JPEGEncodeParam getJPEGEncodeParam()
JPEGEncodeParam getDefaultJPEGEncodeParam(BufferedImage bi) throws ImageFormatException
void encode(BufferedImage bi) throws IOException, ImageFormatException
If no JPEGEncodeParam object has been provided yet a default one will be created by calling getDefaultJPEGEncodeParam with bi.
bi - The BufferedImage to encode.IOExceptionImageFormatExceptionvoid encode(BufferedImage bi, JPEGEncodeParam jep) throws IOException, ImageFormatException
This call also sets the current JPEGEncodeParam object. The given JPEGEncodeParam object will be used for this and future encodings. If jep is null then a new JPEGEncodeParam object will be created by calling getDefaultJPEGEncodeParam with bi.
bi - The BufferedImage to encode.jep - The JPEGEncodeParam object used to control the encoding.IOExceptionImageFormatExceptionint getDefaultColorId(ColorModel cm)
cm - The ColorModel to map to an jpeg encoded COLOR_ID.JPEGEncodeParam getDefaultJPEGEncodeParam(Raster ras, int colorID) throws ImageFormatException
JPEGEncodeParam getDefaultJPEGEncodeParam(int numBands, int colorID) throws ImageFormatException
numBands - the number of bands that will be encoded (max of
four).colorID - the COLOR_ID for the encoded data. This is used to
set reasonable defaults in the parameter object. This must match
the number of bands given.ImageFormatExceptionJPEGEncodeParam getDefaultJPEGEncodeParam(JPEGDecodeParam jdp) throws ImageFormatException
jdp - The JPEGDecodeParam object to copy.ImageFormatExceptionvoid encode(Raster ras) throws IOException, ImageFormatException
If no JPEGEncodeParam object has been provided yet a new JPEGEncodeParam object will be created by calling getDefaultJPEGEncodeParam with ras and COLOR_ID_UNKNOWN.
ras - The Raster to encode.IOExceptionImageFormatExceptionvoid encode(Raster ras, JPEGEncodeParam jep) throws IOException, ImageFormatException
ras - The Raster to encode.jep - The JPEGEncodeParam object used to control the encoding.IOExceptionImageFormatExceptionCopyright © 2022. All rights reserved.