|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--org.eclipse.swt.graphics.Image
Instances of this class are graphics which have been prepared
for display on a specific device. That is, they are ready
to paint using methods such as GC.drawImage()
and display on widgets with, for example, Button.setImage().
If loaded from a file format that supports it, an
Image may have transparency, meaning that certain
pixels are specified as being transparent when drawn. Examples
of file formats that support transparency are GIF and PNG.
There are two primary ways to use Images.
The first is to load a graphic file from disk and create an
Image from it. This is done using an Image
constructor, for example:
Image i = new Image(device, "C:\\graphic.bmp");
A graphic file may contain a color table specifying which
colors the image was intended to possess. In the above example,
these colors will be mapped to the closest available color in
SWT. It is possible to get more control over the mapping of
colors as the image is being created, using code of the form:
ImageData data = new ImageData("C:\\graphic.bmp");
RGB[] rgbs = data.getRGBs();
// At this point, rgbs contains specifications of all
// the colors contained within this image. You may
// allocate as many of these colors as you wish by
// using the Color constructor Color(RGB), then
// create the image:
Image i = new Image(device, data);
Applications which require even greater control over the image
loading process should use the support provided in class
ImageLoader.
Application code must explicitely invoke the Image.dispose()
method to release the operating system resources managed by each instance
when those instances are no longer required.
Color,
ImageData,
ImageLoader| Constructor Summary | |
Image(Device device,
int width,
int height)
Constructs a new instance of an Image (empty image). |
|
Image(Device device,
String filename)
Constructs a new instance by loading the Image from the file with the specified name. |
|
| Method Summary | |
boolean |
isDisposed()
This method returns the dispose state for the image. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, toString |
| Constructor Detail |
public Image(Device device,
String filename)
device - - the device on which the image is being createdfilename - - the name of the file with the image data
public Image(Device device,
int width,
int height)
device - - the device on which the image is being createdwidth - - dimension of the Imageheight - - dimension of the Image| Method Detail |
public boolean isDisposed()
true when the image is disposed and
false otherwise.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||