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
Contributor
Posts: 20
Registered: ‎06-25-2010
My Device: Bold 9700
My Carrier: Cincinnati Bell
Accepted Solution

Why cannot Bitmap.GetBitmapResource()

 

I am trying to load a bitmap and I am getting an IllegalArgumentException in JDE 5.0.0 ( haven't compiled against previous JDEs ).  The file exists in the project, in fact, it is even utilized for the Application Icon rollover - which works spendidly.  I created the image in Adobe Illustrator and exported as a 100x75 pixel PNG-24. I produced another PNG this way that exists in the project that loads (for the unrolled over).  I tried to produce another image and load it, with the previous two images (the one that works and the one that doesn't work) in the project and it fails with this dump, too.

 

  Any restrictions on including images in projects?

 

 

Thanks,

   Brandon

 

The simple code:

 

final Bitmap bm1 = Bitmap.getBitmapResource("cameraRollover.png");

 

 

 

The call stack:

 

Thread [StarfaceRecoApp(230)id=321742848] (Suspended (exception IllegalArgumentException))	
	Resource.getIconOffset(byte[], int) line: 158	
	Resource.getIconBytes(byte[], int) line: 188	
	StarfaceRecoAppRIMResources(Resource).findResource(String) line: 63	
	StarfaceRecoAppRIMResources(Resource).getResource(String) line: 103	
	Bitmap.getBitmapResource(String, String) line: 2333	
	Bitmap.getBitmapResource(String) line: 2359	
	MainHubScreen.<init>(StarfaceApp$StarfaceRecoApp) line: 30	
	StarfaceApp$StarfaceRecoApp.<init>() line: 187	
	StarfaceApp$StarfaceRecoApp.main(String[]) line: 27	

 

 

Developer
Posts: 87
Registered: ‎02-26-2010
My Device: Bold 9000
My Carrier: Rogers

Re: Why cannot Bitmap.GetBitmapResource()

Hi,

 

I'm not sure but have you tried doing something like this?

 

 

PNGEncodedImage.getEncodedImageResource("cameraRollover.png").getBitmap()

 

Since it's a PNG image.

 

Contributor
Posts: 20
Registered: ‎06-25-2010
My Device: Bold 9700
My Carrier: Cincinnati Bell

Re: Why cannot Bitmap.GetBitmapResource()

That worked.  I guess it's hit or miss with GetBitmapResource().

 

 

Thanks for your time!

Developer
Posts: 87
Registered: ‎02-26-2010
My Device: Bold 9000
My Carrier: Rogers

Re: Why cannot Bitmap.GetBitmapResource()

Glad I could help :smileysurprised:

Developer
Posts: 516
Registered: ‎07-23-2010
My Device: 9900

Re: Why cannot Bitmap.GetBitmapResource()

[ Edited ]

was your picture in the same package as the class calling it?

Contributor
Posts: 20
Registered: ‎06-25-2010
My Device: Bold 9700
My Carrier: Cincinnati Bell

Re: Why cannot Bitmap.GetBitmapResource()

com.foo.star.screen  was the .java file calling the image that is in com.foo.bar.star.images

Developer
Posts: 516
Registered: ‎07-23-2010
My Device: 9900

Re: Why cannot Bitmap.GetBitmapResource()

you can also try your older code by having the calling class in the same package as the image.