|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.flagstone.transform.util.image.ImageFactory
public final class ImageFactory
ImageFactory is used to generate an image definition object from an image stored in a file, references by a URL or read from an stream. An plug-in architecture allows decoders to be registered to handle different image formats. The ImageFactory provides a standard interface for using the decoders.
Currently PNG, BMP and JPEG encoded images are supported by dedicated decoders. The BufferedImageDecoder can be used to decode any format supported using Java's ImageIO, including PNG, BMP and JPG format images. New decoders can be added by implementing the ImageDecoder interface and registering them in the ImageRegistry.
The defineImage() methods return an Definition (the abstract base class for all objects used to define shapes etc. in a Flash file. The exact class of the object generated depends of the format of the image loaded.
Class | Generated when... |
---|---|
DefineJPEGImage2 | A JPEG encoded image is loaded. The getFormat() method returns the class constant JPEG. |
DefineImage | An indexed BMP or PNG image contains a colour table without transparent colours or when a true colour image contains 16-bit or 24-bit colours is loaded. The getFormat() method returns the class constants IDX8, RGB5 or RGB8. |
DefineImage2 | A BMP or PNG indexed image contains a colour table with transparent colours is loaded or when a true colour image contains 32-bit bit colours. The getFormat() method returns the class constants IDXA or RGBA. |
Images are displayed in Flash by filling a shape with the image bitmap. The defineEnclosingShape() method generates a rectangular shape object which wraps the image:
int imageId = movie.newIdentifier(); int shapeId = movie.newIdentifier(); Definition image = Image(defineImage(imageId, ...); int x = image.getWidth()/2; int y = image.getHeight()/2; LineStyle style = new LineStyle(20, ColorTable.black()); movie.add(image); movie.add(Image.defineEnclosingShape(shapeId, image, x, y, style);
Here the origin, used when placing the shape on the screen, is defined as the centre of the shape. Other points may be defined to suit the alignment of the shape when it is placed on the display list.
Constructor Summary | |
---|---|
ImageFactory()
|
Method Summary | |
---|---|
ImageTag |
defineImage(int identifier)
Create a definition for the image so it can be added to a Flash movie. |
ImageDecoder |
getDecoder()
Get the ImageDecoder used to decode the image. |
void |
read(File file)
Create an image definition for the image located in the specified file. |
void |
read(InputStream stream)
Create an image definition for an image read from a stream. |
void |
read(URL url)
Create an image definition for the image referenced by a URL. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ImageFactory()
Method Detail |
---|
public void read(File file) throws IOException, DataFormatException
file
- a file containing the abstract path to the image.
IOException
- if there is an error reading the file.
DataFormatException
- if there is a problem decoding the image, either it is in an
unsupported format or an error occurred while decoding the
image data.public void read(URL url) throws IOException, DataFormatException
url
- the Uniform Resource Locator referencing the file.
IOException
- if there is an error reading the file.
DataFormatException
- if there is a problem decoding the image, either it is in an
unsupported format or an error occurred while decoding the
image data.public void read(InputStream stream) throws IOException, DataFormatException
stream
- the InputStream containing the image data.
IOException
- if there is an error reading the stream.
DataFormatException
- if there is a problem decoding the image, either it is in an
unsupported format or an error occurred while decoding the
image data.public ImageTag defineImage(int identifier)
identifier
- the unique identifier for the image.
public ImageDecoder getDecoder()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |