How do I get bundled images with the BlackBerry Eclipse Plugin 1.1 Beta? I copied an image into "res/background.jpg" and tried to load it using Bitmap.getBitmapResource
on background.jpg. Unfortunately, the image wasn't found (Illegal argument exception). I tried moving my image file into the src folder as per the advice here, but that didn't work either. I have opened up the .jar file and the background image is present at the root of the .jar file. The option to convert image files to .png isn't selected either.
Links
Two things:
res
folder needs to be a "source directory" in Eclipse. You can achieve this by right-clicking on the folder and going to "Build Path" -> "Use As Source Folder".Bitmap.getBitmapResource()
, like Michael B. said above, you shouldn't put the folder name in the path. Just call Bitmap.getBitmapResource("background.jpg");
Finally, I'm assuming that because your resource is called "background.jpg" you want it to be the background for a Screen. If this is the case, make sure to set the background using the Screen's Main Manager instead of on the screen itself. For example:
public class MyScreen extends MainScreen
{
public MyScreen() {
getMainManager().setBackground(
BackgroundFactory.createBitmapBackground(
Bitmap.getBitmapResource("background.jpg")));
}
}
When you added the resource to the res folder, did you perform a refresh of the project in Eclipse? If it doesn't 'see' it, the packager ignores it. If you restarted Eclipse, it would pick it up the next time, which might explain why it started working randomly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With