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

£可爱£侵袭症+ 提交于 2019-12-23 01:38:10

问题


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.



来源:https://stackoverflow.com/questions/47543568/how-do-you-utilize-swts-hi-dpi-support-for-icons

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!