Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
AndyM1974
Posts: 7
Registered: ‎02-17-2010
My Device: Curve

Loading Image from resource

Hi,

 

I am new to BB development and am running into issues trying to load a PNG from the resources.

 

I am developing in Eclipse (Ganymede Version: 3.4.1 Build id: M20080911-1700, Plugin 1.0.0.67), targeting JDE4.6.0.

 

Searching posts online it seems that you just need to import an image into your src folder.  And when the application is complied the image is copied into the cod file.  I have also tried the root folder of the application, but again this doesn't work.

 

Bitmap _img = Bitmap.getBitmapResource(

"logo.png");

_img = Bitmap.getBitmapResource(

"/logo.png");

_img = Bitmap.getBitmapResource(

"src/logo.png");

_img = Bitmap.getBitmapResource(

"/src/logo.png");

I am using the following code to try and load the resource, all of them return a null, and I get a message in the debugger saying that the file cannot be found.

I must be missing something out, but am lost to what it could be.

Any help would be appreciated.

Thanks

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Loading Image from resource

In JDE Land, you need to add the image to your project.  I suspect you need to do the same in Eclipse Land.

New Contributor
AndyM1974
Posts: 7
Registered: ‎02-17-2010
My Device: Curve

Re: Loading Image from resource

Turns out that I am using Galileo not Ganymede.  Not sure if thats the issue?

 

The image is contained in the project, so not sure what else I can do.  I am wondering if you must mark the image as a resource for it to get included in the cod? But cannot find how to do it if this is the way.

 

As you don't use eclipse then obviously hard for you to answer, but is there a way to view the contents of the cod?  Not bothered if this has to be done programatically or with another application.

 

Thanks