public class ImageLoader
extends java.lang.Object
Currently supported image formats are:
ImageLoaders
can be used to:
Modifier and Type | Field and Description |
---|---|
int |
backgroundPixel
the background pixel for the logical screen (this
corresponds to the GIF89a Background Color Index value).
|
int |
compression
This is the compression used when saving jpeg and png files.
|
ImageData[] |
data
the array of ImageData objects in this ImageLoader.
|
int |
logicalScreenHeight
the height of the logical screen on which the images
reside, in pixels (this corresponds to the GIF89a
Logical Screen Height value)
|
int |
logicalScreenWidth
the width of the logical screen on which the images
reside, in pixels (this corresponds to the GIF89a
Logical Screen Width value)
|
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").
|
Constructor and Description |
---|
ImageLoader()
Construct a new empty ImageLoader.
|
Modifier and Type | Method and Description |
---|---|
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.
|
boolean |
hasListeners()
Returns
true if the receiver has image loader
listeners, and false otherwise. |
ImageData[] |
load(java.io.InputStream stream)
Loads an array of
ImageData objects from the
specified input stream. |
ImageData[] |
load(java.lang.String filename)
Loads an array of
ImageData objects from the
file with the specified name. |
void |
notifyListeners(ImageLoaderEvent event)
Notifies all image loader listeners that an image loader event
has occurred.
|
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.
|
void |
save(java.io.OutputStream stream,
int format)
Saves the image data in this ImageLoader to the specified stream.
|
void |
save(java.lang.String filename,
int format)
Saves the image data in this ImageLoader to a file with the specified name.
|
public ImageData[] data
public int logicalScreenWidth
public int logicalScreenHeight
public int backgroundPixel
public int repeatCount
public int compression
When saving jpeg files, the value is from 1 to 100, where 1 is very high compression but low quality, and 100 is no compression and high quality; default is 75.
When saving png files, the value is from 0 to 3, but they do not impact the quality because PNG is lossless compression. 0 is uncompressed, 1 is low compression and fast, 2 is default compression, and 3 is high compression but slow.
public ImageData[] load(java.io.InputStream stream)
ImageData
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.stream
- the input stream to load the images fromImageData
objects loaded from the specified input streamjava.lang.IllegalArgumentException
- SWTException
- public ImageData[] load(java.lang.String filename)
ImageData
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.filename
- the name of the file to load the images fromImageData
objects loaded from the specified filejava.lang.IllegalArgumentException
- SWTException
- public void save(java.io.OutputStream stream, int format)
IMAGE_BMP
IMAGE_BMP_RLE
IMAGE_GIF
IMAGE_ICO
IMAGE_JPEG
IMAGE_PNG
stream
- the output stream to write the images toformat
- the format to write the images injava.lang.IllegalArgumentException
- SWTException
- public void save(java.lang.String filename, int format)
IMAGE_BMP
IMAGE_BMP_RLE
IMAGE_GIF
IMAGE_ICO
IMAGE_JPEG
IMAGE_PNG
filename
- the name of the file to write the images toformat
- the format to write the images injava.lang.IllegalArgumentException
- SWTException
- public void addImageLoaderListener(ImageLoaderListener listener)
An ImageLoaderListener should be added before invoking
one of the receiver's load methods. The listener's
imageDataLoaded
method is called when image
data has been partially loaded, as is supported by interlaced
GIF/PNG or progressive JPEG images.
listener
- the listener which should be notifiedjava.lang.IllegalArgumentException
- ImageLoaderListener
,
ImageLoaderEvent
public void removeImageLoaderListener(ImageLoaderListener listener)
listener
- the listener which should no longer be notifiedjava.lang.IllegalArgumentException
- addImageLoaderListener(ImageLoaderListener)
public boolean hasListeners()
true
if the receiver has image loader
listeners, and false
otherwise.true
if there are ImageLoaderListener
s, and false
otherwiseaddImageLoaderListener(ImageLoaderListener)
,
removeImageLoaderListener(ImageLoaderListener)
public void notifyListeners(ImageLoaderEvent event)
event
- the ImageLoaderEvent
to send to each ImageLoaderListener
Copyright (c) EclipseSource and others 2002, 2017.
All rights reserved. This program and the accompanying materials
are made available under the terms of the
Eclipse Public License v1.0