com.flagstone.transform.util.image
Class BufferedImageDecoder

java.lang.Object
  extended by com.flagstone.transform.util.image.BufferedImageDecoder
All Implemented Interfaces:
ImageDecoder, ImageProvider

public final class BufferedImageDecoder
extends Object
implements ImageProvider, ImageDecoder

BufferedImageDecoder decodes BufferedImages so they can be used in a Flash file. The class also provides a set of convenience methods for converting Flash images definitions into BufferedImages allowing the images to easily be extracted from a Flash movie.


Constructor Summary
BufferedImageDecoder()
           
 
Method Summary
 ImageTag defineImage(int identifier)
          Create the image definition so it can be added to a movie.
 ImageTag defineImage(int identifier, BufferedImage obj)
          Create an image definition from a BufferedImage.
 int getHeight()
          Get the height of the image.
 byte[] getImage()
          Get the array of bytes that make up the image.
 int getWidth()
          Get the width of the image.
 ImageDecoder newDecoder()
          The method implemented by all ImageDecoders in order to be registered with the ImageRegistry and used by the ImageFactory to decode images.
 void read(BufferedImage obj)
          Decode a BufferedImage.
 void read(File file)
          Read an image from a file.
 void read(InputStream stream)
          Read an image from an input stream.
 void read(URL url)
          Read an image from a file referenced by a URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BufferedImageDecoder

public BufferedImageDecoder()
Method Detail

newDecoder

public ImageDecoder newDecoder()
The method implemented by all ImageDecoders in order to be registered with the ImageRegistry and used by the ImageFactory to decode images.

Specified by:
newDecoder in interface ImageProvider
Returns:
an object that implements the FontDecoder interface.

read

public void read(File file)
          throws IOException,
                 DataFormatException
Read an image from a file.

Specified by:
read in interface ImageDecoder
Parameters:
file - the path to the file.
Throws:
IOException - if there is an error reading the image data.
DataFormatException - if the file contains an unsupported format.

read

public void read(URL url)
          throws IOException,
                 DataFormatException
Read an image from a file referenced by a URL.

Specified by:
read in interface ImageDecoder
Parameters:
url - the reference to the file.
Throws:
IOException - if there is an error reading the image data.
DataFormatException - if the file contains an unsupported format.

read

public void read(InputStream stream)
          throws IOException,
                 DataFormatException
Read an image from an input stream.

Specified by:
read in interface ImageDecoder
Parameters:
stream - the stream used to read the image data.
Throws:
IOException - if there is an error reading the image data.
DataFormatException - if the file contains an unsupported format.

defineImage

public ImageTag defineImage(int identifier)
Create the image definition so it can be added to a movie.

Specified by:
defineImage in interface ImageDecoder
Parameters:
identifier - the unique identifier used to refer to the image.
Returns:
the image definition.

defineImage

public ImageTag defineImage(int identifier,
                            BufferedImage obj)
                     throws IOException,
                            DataFormatException
Create an image definition from a BufferedImage.

Parameters:
identifier - the unique identifier that will be used to refer to the image in the Flash file.
obj - the BufferedImage containing the image.
Returns:
an image definition that can be added to a Movie.
Throws:
IOException - if there is a problem extracting the image, from the BufferedImage.
DataFormatException - if the BufferedImage contains a format that is not currently supported.

getWidth

public int getWidth()
Get the width of the image.

Specified by:
getWidth in interface ImageDecoder
Returns:
the width of the image in pixels.

getHeight

public int getHeight()
Get the height of the image.

Specified by:
getHeight in interface ImageDecoder
Returns:
the height of the image in pixels.

getImage

public byte[] getImage()
Get the array of bytes that make up the image. This method is used by the ImageFactory to generate a list of blocks for encoding an image as ScreenVideo.

Specified by:
getImage in interface ImageDecoder
Returns:
the array of bytes representing the image.

read

public void read(BufferedImage obj)
          throws IOException,
                 DataFormatException
Decode a BufferedImage.

Parameters:
obj - a BufferedImage.
Throws:
IOException - if there is a problem extracting the image, from the BufferedImage.
DataFormatException - if there is a problem decoding the BufferedImage.


Copyright © 2002-2010 Flagstone Software Ltd.. All Rights Reserved.