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 theSerializerinterface that reads and writes instances ofBufferedImage.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBufferedImageSerializer.FormatSupported image formats.
-
Constructor Summary
Constructors Constructor Description BufferedImageSerializer()Construct an image serializer for the defaultPNGformat.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.StringgetMIMEType(java.awt.image.BufferedImage bufferedImage)Returns the MIME type of the data read and written by this serializer.BufferedImageSerializer.FormatgetOutputFormat()java.awt.image.BufferedImagereadObject(java.io.InputStream inputStream)Reads a serialized image from an input stream.voidsetOutputFormat(BufferedImageSerializer.Format outputFormat)Sets the image format that this serializer should use for output.voidwriteObject(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 defaultPNGformat.
-
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, SerializationExceptionReads a serialized image from an input stream.- Specified by:
readObjectin interfaceSerializer<java.awt.image.BufferedImage>- Parameters:
inputStream- The stream to read the image from.- Returns:
- A
BufferedImageobject - 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, SerializationExceptionWrites a buffered image to an output stream.- Specified by:
writeObjectin 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:SerializerReturns the MIME type of the data read and written by this serializer.- Specified by:
getMIMETypein 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.
-
-