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

2019-08-02 08:57发布

问题:

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?

回答1:

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.



回答2:

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.



标签: java swt jface