Platform and Equinox API

Platform Changes

SWT Changes

Constructor for Dynamically Scaled, Custom-Drawn Image

The Image class provides a constructor for creating an empty image based on a concrete size, which is then usually filled programmatically via a GC. Such an image will be created according to a fixed zoom value. When the image is requested in a different zoom via getImageData(zoom), the image will be raster-scaled, leading to blurry results.

The API has been extended as follows to address this limitation:

  • A new constructor has been added to the Image class:
    Image(Device device, ImageGcDrawer imageGcDrawer, int width, int height)
  • The constructor accepts implementations of ImageGcDrawer defining the method:
    drawOn(GC gc, int imageWidth, int imageHeight)

Such an image will call imageGcDrawer.drawOn(...) whenever the image data for a different zoom is requested to generate that data in a size as required for the specified zoom.

To be prepared for enhanced UI scaling mechanisms, such as the monitor-specific scaling feature on windows (see this news), this new constructor should be preferred for programmatic creation of images instead of the existing constructors using a fixed size.

Previous Up Next