Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Secko is correct that you can override paint but I think you are getting stuck because you have not created a ui application.</p> <p>Here is a very simple ui application example for displaying a bitmap field, if you copy it exactly you will need an images folder under src with image.png inside of it.</p> <p>This was modified from the HelloWorldDemo that comes with the SDK. I recommend that if you are just starting out you look at the samples in the folder. \plugins\net.rim.ejde.componentpack5.0.0_5.0.0.25\components\samples\</p> <p>good luck</p> <p>Ray</p> <pre><code>public class DisplayBitmaps extends UiApplication { public static void main(String[] args) { DisplayBitmaps theApp = new DisplayBitmaps(); theApp.enterEventDispatcher(); } public DisplayBitmaps() { pushScreen(new DisplayBitmapsScreen()); } } final class DisplayBitmapsScreen extends MainScreen { DisplayBitmapsScreen() { Bitmap bitmap = EncodedImage.getEncodedImageResource("images/image.png").getBitmap(); BitmapField bitmapField = new BitmapField(bitmap); add(bitmapField); } public void close() { super.close(); } } </code></pre> <p>Edit for when the image is on the sdcard</p> <pre><code>DisplayBitmapsScreen() { //Bitmap bitmap = EncodedImage.getEncodedImageResource("images/image.png").getBitmap(); try { FileConnection fc = (FileConnection) Connector.open("file:///SDCard/BlackBerry/pictures/image.png"); if (fc.exists()) { byte[] image = new byte[(int) fc.fileSize()]; InputStream inStream = fc.openInputStream(); inStream.read(image); inStream.close(); EncodedImage encodedImage = EncodedImage.createEncodedImage(image, 0, -1); BitmapField bitmapField = new BitmapField(encodedImage.getBitmap()); fc.close(); add(bitmapField); } } catch (Exception e) { System.out.println("EXCEPTION " + e); } } </code></pre> <p>Overriding paint in Field or any extension Field class could also display an image, but I didn't really understand from Secko's example where he would display the image so I have included drawImage in this example below.</p> <pre><code>protected void paint(Graphics graphics) { graphics.drawImage(x, y, width, height, image, frameIndex, left, top); super.paint(graphics); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload