hidpi/dark images in Plugins

<oXygen/> general issues.
patrick
Posts: 96

hidpi/dark images in Plugins

Wed Dec 02, 2015 7:55 pm

Hi,

how to use images/icons in plugins that automatically will be changed in hidpi/dark settings?

Best regards,
Patrick
Radu
Posts: 5585

Re: hidpi/dark images in Plugins

Thu Dec 03, 2015 11:21 am

Hi Patrick,

So let's say your plugin adds a new toolbar button with your custom image.
Somewhere in an "images" folder you have an image called let's say myImage.png which you currently use for that button.
Besides that image in the same folder you should have another image called myImagee@2x.png which should be twice as large as the original image (both vertically and horizontally). This image will be used for Mac Retina displays for example.
And you should also create and have in the same folder the equivalent images to be used for the dark themes: myImage_dark.png and myImage_dark@2x.png.

Then you can use our API ro.sync.ui.Icons.getIcon(String iconKey). The icon key should be an URL pointing to the original image myImage.png. Depending on whether Oxygen is running in retina display with or without dark theme, the API will load either the original image or one of the other images located in the same place.
If you do not want to manually create the dark image, we have an API which would allow you to check if Oxygen is running in dark mode:

WorkspaceUtilities.getColorTheme()

and we also have an image inverter API:

WorkspaceUtilities.getImageInverter()

but for supporting hidpi you will need to create the larger icon by yourself.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Radu
Posts: 5585

Re: hidpi/dark images in Plugins

Thu Dec 03, 2015 11:22 am

One more thing:

A similar procedure is done if you have a framework and use in the CSS various icons:

https://www.oxygenxml.com/doc/versions/17.1/ug-editor/#topics/using-retina-hidpi-images.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Return to “Other Issues”

Who is online

Users browsing this forum: No registered users and 0 guests