ohmu
ohmu

Reputation: 19762

How do you utilize SWT's Hi-DPI support for icons?

According to Eclipse Project Neon - New and Noteworthy, SWT supports auto-scaling for Hi-DPI monitors. Does SWT only support "auto-scaling", or does it provide additional features such as defining different images for various DPIs or zoom levels? If so, what are the classes I need to be looking into?

Upvotes: 1

Views: 459

Answers (2)

greg-449
greg-449

Reputation: 111142

The JFace ImageDescriptor createFromFile and createFromURL methods look for additional image files with the name ending in @2x or @1.5x and will use these with an SWT image data provider when creating images.

Upvotes: 3

Rüdiger Herrmann
Rüdiger Herrmann

Reputation: 20985

SWT's Image has a new constructor that accepts an ImageDataProvider in order to provide image data for different zoom levels. if the application is moved to a monitor with different DPI or the zoom level is changed, the provider will be asked to return an image for the new zoom level (e.g. 150 or 200).

For the sake of completeness, there is also an ImageFileNameProvider. It works similar to the ImageDataProvider but returns file names instead.

Upvotes: 3

Related Questions