public class BufferedImageSerializer
extends java.lang.Object
implements Serializer<java.awt.image.BufferedImage>
Implementation of the
Serializer
interface that reads and writes
instances of
BufferedImage
.
writeObject
(java.awt.image.BufferedImage bufferedImage,
java.io.OutputStream outputStream)
Writes a buffered image to an output stream.
BufferedImageSerializer
public BufferedImageSerializer(BufferedImageSerializer.Format outputFormat)
Construct an image serializer for the given format.
Parameters:
outputFormat
- The output format for this serializer.
setOutputFormat
public void setOutputFormat(BufferedImageSerializer.Format outputFormat)
Sets the image format that this serializer should use for output.
Parameters:
outputFormat
- The new format to use for output.
readObject
public java.awt.image.BufferedImage readObject(java.io.InputStream inputStream)
throws java.io.IOException,
SerializationException
Reads a serialized image from an input stream.
Specified by:
readObject
in interface
Serializer
<java.awt.image.BufferedImage>
Parameters:
inputStream
- The stream to read the image from.
Returns:
A
BufferedImage
object
Throws:
java.io.IOException
- for any errors accessing or reading the object.
SerializationException
- for any formatting errors encountered
while deserializing the object.
writeObject
public void writeObject(java.awt.image.BufferedImage bufferedImage,
java.io.OutputStream outputStream)
throws java.io.IOException,
SerializationException
Writes a buffered image to an output stream.
Specified by:
writeObject
in interface
Serializer
<java.awt.image.BufferedImage>
Parameters:
bufferedImage
- The image to write out to the stream.
outputStream
- The stream to write the image out to.
Throws:
java.io.IOException
- for any errors accessing or reading the object.
SerializationException
- for any formatting errors encountered
while deserializing the object.
getMIMEType
public final java.lang.String getMIMEType(java.awt.image.BufferedImage bufferedImage)
Returns the MIME type of the data read and written by this serializer.
Specified by:
getMIMEType
in interface
Serializer
<java.awt.image.BufferedImage>
Parameters:
bufferedImage
- If provided, allows the serializer to attach parameters to
the returned MIME type containing more detailed information about the
data. If
null
, the base MIME type is returned.
Returns:
The MIME type of the current data.