ImageLoader

Instances of this class are used to load images from, and save images to, a file or stream. <p> Currently supported image formats are: </p><ul> <li>BMP (Windows or OS/2 Bitmap)</li> <li>ICO (Windows Icon)</li> <li>JPEG</li> <li>GIF</li> <li>PNG</li> <li>TIFF</li> </ul> <code>ImageLoaders</code> can be used to: <ul> <li>load/save single images in all formats</li> <li>load/save multiple images (GIF/ICO/TIFF)</li> <li>load/save animated GIF images</li> <li>load interlaced GIF/PNG images</li> <li>load progressive JPEG images</li> </ul>

@see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ImageAnalyzer</a> @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>

Constructors

this
this()

Construct a new empty ImageLoader.

Members

Functions

addImageLoaderListener
void addImageLoaderListener(ImageLoaderListener listener)

Adds the listener to the collection of listeners who will be notified when image data is either partially or completely loaded. <p> An ImageLoaderListener should be added before invoking one of the receiver's load methods. The listener's <code>imageDataLoaded</code> method is called when image data has been partially loaded, as is supported by interlaced GIF/PNG or progressive JPEG images.

hasListeners
bool hasListeners()

Returns <code>true</code> if the receiver has image loader listeners, and <code>false</code> otherwise.

load
ImageData[] load(InputStream stream)

Loads an array of <code>ImageData</code> objects from the specified input stream. Throws an error if either an error occurs while loading the images, or if the images are not of a supported type. Returns the loaded image data array.

load
ImageData[] load(String filename)

Loads an array of <code>ImageData</code> objects from the file with the specified name. Throws an error if either an error occurs while loading the images, or if the images are not of a supported type. Returns the loaded image data array.

notifyListeners
void notifyListeners(ImageLoaderEvent event)

Notifies all image loader listeners that an image loader event has occurred. Pass the specified event object to each listener.

removeImageLoaderListener
void removeImageLoaderListener(ImageLoaderListener listener)

Removes the listener from the collection of listeners who will be notified when image data is either partially or completely loaded.

reset
void reset()

Resets the fields of the ImageLoader, except for the <code>imageLoaderListeners</code> field.

save
void save(OutputStream stream, int format)

Saves the image data in this ImageLoader to the specified stream. The format parameter can have one of the following values: <dl> <dt><code>IMAGE_BMP</code></dt> <dd>Windows BMP file format, no compression</dd> <dt><code>IMAGE_BMP_RLE</code></dt> <dd>Windows BMP file format, RLE compression if appropriate</dd> <dt><code>IMAGE_GIF</code></dt> <dd>GIF file format</dd> <dt><code>IMAGE_ICO</code></dt> <dd>Windows ICO file format</dd> <dt><code>IMAGE_JPEG</code></dt> <dd>JPEG file format</dd> <dt><code>IMAGE_PNG</code></dt> <dd>PNG file format</dd> </dl>

save
void save(String filename, int format)

Saves the image data in this ImageLoader to a file with the specified name. The format parameter can have one of the following values: <dl> <dt><code>IMAGE_BMP</code></dt> <dd>Windows BMP file format, no compression</dd> <dt><code>IMAGE_BMP_RLE</code></dt> <dd>Windows BMP file format, RLE compression if appropriate</dd> <dt><code>IMAGE_GIF</code></dt> <dd>GIF file format</dd> <dt><code>IMAGE_ICO</code></dt> <dd>Windows ICO file format</dd> <dt><code>IMAGE_JPEG</code></dt> <dd>JPEG file format</dd> <dt><code>IMAGE_PNG</code></dt> <dd>PNG file format</dd> </dl>

Variables

backgroundPixel
int backgroundPixel;

the background pixel for the logical screen (this corresponds to the GIF89a Background Color Index value). The default is -1 which means 'unspecified background'

data
ImageData[] data;

the array of ImageData objects in this ImageLoader. This array is read in when the load method is called, and it is written out when the save method is called

logicalScreenHeight
int logicalScreenHeight;

the height of the logical screen on which the images reside, in pixels (this corresponds to the GIF89a Logical Screen Height value)

logicalScreenWidth
int logicalScreenWidth;

the width of the logical screen on which the images reside, in pixels (this corresponds to the GIF89a Logical Screen Width value)

repeatCount
int repeatCount;

the number of times to repeat the display of a sequence of animated images (this corresponds to the commonly-used GIF application extension for "NETSCAPE 2.0 01"). The default is 1. A value of 0 means 'display repeatedly'

Meta