Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Problem creating image from a file in a bundle
Problem creating image from a file in a bundle [message #327745] Wed, 30 April 2008 07:54 Go to next message
Jan Weidauer is currently offline Jan WeidauerFriend
Messages: 49
Registered: July 2009
Member
Hi there,

in my plugin I try to create an image using a file in a separate
directory of my plugin. I use the code below to do this. But when doing
so, the image has a width and height of -1. Does anyone have a hint to
resolve this problem?

Image img =
ImageDescriptor.createFromURL(FileLocator.find(Activator.get Default().getBundle(),
new Path("data/EclipseBannerPic.jpg"),
null)).createImage(parent.getDisplay());

Thanks in advance

Jan
Re: Problem creating image from a file in a bundle [message #327751 is a reply to message #327745] Wed, 30 April 2008 12:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Jan,

Have you inspected the URL that comes back? What does it look like?
Does openStream on the URL return a stream without throwing an
exception? The "data" folder is at the root of your plugin? Usually
people use an "icons" folder. You've specified it in your
build.properties so it's included in the final jarred plugin when you
export?


Jan Weidauer wrote:
> Hi there,
>
> in my plugin I try to create an image using a file in a separate
> directory of my plugin. I use the code below to do this. But when doing
> so, the image has a width and height of -1. Does anyone have a hint to
> resolve this problem?
>
> Image img =
> ImageDescriptor.createFromURL(FileLocator.find(Activator.get Default().getBundle(),
> new Path("data/EclipseBannerPic.jpg"),
> null)).createImage(parent.getDisplay());
>
> Thanks in advance
>
> Jan
>
Re: Problem creating image from a file in a bundle [message #327772 is a reply to message #327745] Wed, 30 April 2008 23:23 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

also, most of the logic is already written for you in
org.eclipse.ui.plugin.AbstractUIPlugin.imageDescriptorFromPl ugin(String,
String)

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Previous Topic:Popup Menu "Test" definition not working
Next Topic:[Databinding] ObservableListContentProvider for TreeViewers?
Goto Forum:
  


Current Time: Sat Nov 09 03:48:04 GMT 2024

Powered by FUDForum. Page generated in 0.04021 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top