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 explicitly invoke the Image.dispose()
method to release the operating system resources managed by each instance
when those instances are no longer required.
GC.drawImage()and display on widgets with, for example,Button.setImage().If loaded from a file format that supports it, an
Imagemay 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 anImagefrom it. This is done using anImageconstructor, 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 explicitly invoke the
Image.dispose()method to release the operating system resources managed by each instance when those instances are no longer required.