Skip to content

Picture

greipadmin edited this page Feb 7, 2017 · 15 revisions

Introduction

This widget simply shows a Picture. Supported picture formats: PNG, BMP, JPEG, GIF (including animated GIFs), ICO and TIFF.

Constructors

  • Picture(Composite parent, int style)
  • parent a widget which will be the parent of the new Picture widget.
  • style the style of widget to construct.

Methods

  • loadImage(String) loads an image from the file with the specified name.
  • loadImage(InputStream) loads an image from the specified input stream.
  • setImage(Image) sets the image.
  • scaleTo(Point) scale the image to specified size. Default is Point(SWT.DEFAULT, SWT.DEFAULT), that means the original image size. Point(100, SWT.DEFAULT) means scale to width 100px and calculate the new height.

The size of the widget is the scaled size of the image. Is no image loaded, the size is Point(0, 0).

Example

final Picture picture = new Picture(shell, SWT.BORDER);

final FileDialog dialog = new FileDialog(shell);
dialog.setFilterExtensions(new String[] { "*.bmp;*.gif;*.jpg;*.png" });
final String filename = dialog.open();

if (filename != null) {
	picture.loadImage(filename);
}
Clone this wiki locally