Accessing image in eclipse plugin

I am trying to set a canvas background image with

canvas.setBackgroundImage(image);

      

How to install an image with a * .png file stored in the plugin image subdirectory?

Something like that:

PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK)

      

but I want to use my image file instead of the generic image.

+2


source to share


1 answer


For images not declared in plugin.xml like in this thread :

 public Image createImage(String path) {
   Image image = getImageRegistry().get(path);
   if (image == null) {
     getImageRegistry().put(path, AbstractUIPlugin.
       imageDescriptorFromPlugin(ID, path));
     image = getImageRegistry().get(path);
   }
   return image;
 }

      



(similar to " Frequently Asked Questions How do I create an image registry for my plugin? ")

See Also UI Resources for accessing resources declared in your plugin.

+3


source







All Articles