Skip to content

Picture

greipadmin edited this page Dec 31, 2018 · 15 revisions

Introduction

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

Constructor

  • 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

  • void loadImage(String) loads an image from the file with the specified name.
  • void loadImage(InputStream) loads an image from the specified input stream.
  • void setImage(Image) sets the image.
  • void 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.
  • void setBorderWidth(int) sets the border width.
  • int getBorderWidth() returns the current border width.
  • void setBorderColor(Color) sets the border color.
  • Color getBorderColor() returns the current border color.

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