Package org.apache.pivot.wtk.media
Class BufferedImageSerializer
- java.lang.Object
-
- org.apache.pivot.wtk.media.BufferedImageSerializer
-
- All Implemented Interfaces:
Serializer<java.awt.image.BufferedImage>
public class BufferedImageSerializer extends java.lang.Object implements Serializer<java.awt.image.BufferedImage>
Implementation of theSerializer
interface that reads and writes instances ofBufferedImage
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BufferedImageSerializer.Format
Supported image formats.
-
Constructor Summary
Constructors Constructor Description BufferedImageSerializer()
Construct an image serializer for the defaultPNG
format.BufferedImageSerializer(BufferedImageSerializer.Format outputFormat)
Construct an image serializer for the given format.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getMIMEType(java.awt.image.BufferedImage bufferedImage)
Returns the MIME type of the data read and written by this serializer.BufferedImageSerializer.Format
getOutputFormat()
java.awt.image.BufferedImage
readObject(java.io.InputStream inputStream)
Reads a serialized image from an input stream.void
setOutputFormat(BufferedImageSerializer.Format outputFormat)
Sets the image format that this serializer should use for output.void
writeObject(java.awt.image.BufferedImage bufferedImage, java.io.OutputStream outputStream)
Writes a buffered image to an output stream.
-
-
-
Constructor Detail
-
BufferedImageSerializer
public BufferedImageSerializer()
Construct an image serializer for the defaultPNG
format.
-
BufferedImageSerializer
public BufferedImageSerializer(BufferedImageSerializer.Format outputFormat)
Construct an image serializer for the given format.- Parameters:
outputFormat
- The output format for this serializer.
-
-
Method Detail
-
getOutputFormat
public BufferedImageSerializer.Format getOutputFormat()
- Returns:
- The image format that this serializer is using for output.
-
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 interfaceSerializer<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 interfaceSerializer<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)
Description copied from interface:Serializer
Returns the MIME type of the data read and written by this serializer.- Specified by:
getMIMEType
in interfaceSerializer<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. Ifnull
, the base MIME type is returned.- Returns:
- The MIME type of the current data.
-
-