|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
JPEGImageEncoder encodes buffers of image data into JPEG data
streams. Users of this interface are required to provide image data in
a Raster or a BufferedImage, set the necessary parameters in the
JPEGEncodeParams object and successfully open the
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
Method Summary | |
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. |
Method Detail |
public OutputStream getOutputStream()
public void setJPEGEncodeParam(JPEGEncodeParam jep)
jep
- The JPEGEncodeParam object to use for future encodings.public JPEGEncodeParam getJPEGEncodeParam()
public JPEGEncodeParam getDefaultJPEGEncodeParam(BufferedImage bi) throws ImageFormatException
ImageFormatException
public 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.
IOException
ImageFormatException
public void 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.
IOException
ImageFormatException
public int getDefaultColorId(ColorModel cm)
cm
- The ColorModel to map to an jpeg encoded COLOR_ID.
public JPEGEncodeParam getDefaultJPEGEncodeParam(Raster ras, int colorID) throws ImageFormatException
ImageFormatException
public 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.
ImageFormatException
public JPEGEncodeParam getDefaultJPEGEncodeParam(JPEGDecodeParam jdp) throws ImageFormatException
jdp
- The JPEGDecodeParam object to copy.
ImageFormatException
public void 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.
IOException
ImageFormatException
public void encode(Raster ras, JPEGEncodeParam jep) throws IOException, ImageFormatException
ras
- The Raster to encode.jep
- The JPEGEncodeParam object used to control the encoding.
IOException
ImageFormatException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |