To simplify the example code, I only show you how to get ImageDescriptor. After that, you can use createImage() to crate Image object from
1. Icons Folder Inside RCP project
Activator.getImageDescriptor("icons/tray.png");
2. from class path
If images are saved in the same place as your class:
ImageDescriptor.createFromFile(
BookCoverView.class, "cover.jpg");
3. from external disk or Internet
This is helpful when you ask user to specify a image from their disk.ImageDescriptor.createFromURL(
new URL("file:d://icons/info2.gif"));
4. reuse Eclipse's icons
Many common images (undo, redo, file, folder, cut, copy) are available thru the org.eclipse.ui.ISharedImages interface. You can get them with IWorkbench:
PlatformUI.getWorkbench().getSharedImages() .getImage(ISharedImages.IMG_OBJ_FOLDER);
source: http://blog.cypal-solutions.com/2008/02/eclipse-icons.html
5. Access icons from other plugin
access the icons from other plugins without bundling them in your plugin:
AbstractUIPlugin.imageDescriptorFromPlugin( "org.eclipse.ui", "$nl$/icons/import_wiz.gif");
source: http://blog.cypal-solutions.com/2008/02/eclipse-icons-follow-up-post.html
1 comments:
Hi, I have command (RCP app) which use image from other plugin(../otherPlugin/im.gif). When I run it in workspace everything is OK, but after exporting to exe images disapear. Any suggestion ?
Thanks, Petr
Post a Comment