Images in a plugin are usually placed in an images
or icons
folder - don't forget to add this folder to the build.properties
so that it will be included in the built plugin.
You load images from the folder using:
final URL fullPathString = FileLocator.find(bundle, new Path(path), null);
ImageDescriptor imageDesc = ImageDescriptor.createFromURL(fullPathString);
Image image = imageDesc.createImage();
bundle
is your plugin Bundle
, you can get this from your Activator (if you have one) or using:
Bundle bundle = Platform.getBundle("plugin id");
or
Bundle bundle = FrameworkUtil.getBundle(getClass());
path
is the image path relative to the plugin - so something like images/xxx.gif
If you create an Image
you must dispose of it when done (ImageDescriptor
does not need to be disposed).
You can use org.eclipse.jface.resource.ImageRegistry
to manage the images and image descriptors.
Update:
Once you have an ImageDescriptor
you set it as the title image on a wizard page by calling WizardPage.setImageDescriptor(descriptor)
.