Skip to content

Picture

greipadmin edited this page Jan 27, 2019 · 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 filename) loads an image from the file with the specified name.
  • void loadImage(InputStream stream) loads an image from the specified input stream.
  • void setImage(Image image) sets the image.
  • void scaleTo(Point size) 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 width) sets the border width.
  • int getBorderWidth() returns the current border width.
  • void setBorderColor(Color color) sets the border color.
  • Color getBorderColor() returns the current border color.
  • void setCornerRadius(int radius) set the radius of rounded corners.
  • int getCornerRadius() returns the radius of rounded corners.

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

Examples

  • Sample1 allows the selection of an image and then displays it with a fixed height
  • Sample2 displays an animated GIF and surrounds it with a border that has rounded corners
Clone this wiki locally