views:

84

answers:

1

I'm trying to set the background image of canvas using

canvas.setBackgroundImage(image);

How can i set the image with a *.png file that is stored in plugin's image sub-directory ?

Something like this:

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

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

+1  A: 

For images not declared in the 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 "FAQ How do I create an image registry for my plug-in?")

See also User interface resources for accessing resources declared within your plugin.

VonC
Thanks for the answer, also FAQ page is very helpful..
penguru