Adding a Bitmap Image to an App

Hello

I am very new to Blackberry development, but I'll try to explain my problem in as much detail as possible.

I would have a bitmap to load up when I run my application. The code I used is as follows:

If you want to continue the reasons why install OTA is not working, may I suggest that you advance in the tests that I mentioned in my previous post.

Alternatively, if you are happy, that the problem is solved, can mark you as well.

Tags: BlackBerry Developers

Similar Questions

  • Bitmap image does not appear when other fields added

    Hello

    I have a VerticalFieldManager with a bitmap and a few fields (code below).
    I add to an another VFM then call setBitmapField when the tile is
    downloaded in another thread.

    The code below when the bitmap is set, the other fields, move to the
    right to leave a space for the bitmap image, but the image bitmap is not visible.

    If I remove:

    This.Add (this.authorField);

    and code layout corresponding to sublayout, the bitmap fine watch.

    What I am doing wrong?

    ---

    class Item extends VerticalFieldManager {
    
        public BitmapField thumbField;
        public Bitmap image = null;
        private LabelField titleField;
        public LabelField authorField;
    
        public Item(ItemData item) {
    
            this.thumbField = new BitmapField(); 
    
            this.titleField = new LabelField(item.title, FOCUSABLE);
            Font fnt = this.getFont().derive(Font.PLAIN, titleField.getFont().getHeight() - 1);
            this.titleField.setFont(fnt);
    
            this.authorField = new LabelField(item.author);
            Font fnt2 = this.getFont().derive(Font.PLAIN, authorField.getFont().getHeight() - 3);
            this.authorField.setFont(fnt2);
    
            this.add(this.thumbField);
            this.add(this.titleField);
            this.add(this.authorField);
        }
    
        public void setBitmapField(Bitmap _image) {
            this.image = _image;
            this.thumbField.setBitmap(_image);
            this.invalidate();
        }
    
        protected void sublayout(int width, int height) {
    
             if (getFieldCount() > 0) {
    
                 BitmapField _thumbField = (BitmapField)getField(0);
                 layoutChild(_thumbField, _thumbField.getBitmapWidth(), _thumbField.getBitmapHeight());
                 setPositionChild(_thumbField, 0, 0);
    
                 int thumbWidth = _thumbField.getWidth();
    
                 Field _titleField = getField(1);
                 layoutChild(_titleField, width - thumbWidth, _titleField.getHeight());
                 setPositionChild(_titleField, thumbWidth + 5, 0); 
    
                 Field _authorField = getField(2);
                 layoutChild(_authorField, width - thumbWidth, _authorField.getHeight());
                 setPositionChild(_authorField, thumbWidth + 5, _titleField.getHeight()); 
    
                 setExtent(width, _titleField.getHeight() + _authorField.getHeight() + 2);
             }
         }
    }
    

    I have it! Had to extend Manager rather than VerticalFieldManager. Assumes that the optimization of the resources are so limited in-house as how fields can be arranged. Makes sense.

  • get the Bitmap Image of the web site or remote location

    Hi, yesterday I asked for some ease of image horizontal scorlling with blackberry. It's work very well. Thank you for all.

    But I could not do my job. What I need, that I have to get the Image from a web site (not in the project of ths) and display it in the BB device. I can do this and I get byte array and show the image using BitmapField. But this installation of scrolling does not work with the bitmap field.

    Is is them possible to get my web site dynamic images of the Bitmap object?

    Here is the code that you sent me.

    // ------------------------------------------

    package com.falseflag.blackberry.recipes;

    Import net.rim.device.api.system.Bitmap;
    Import net.rim.device.api.ui.Graphics;
    Import net.rim.device.api.ui.UiApplication;
    Import net.rim.device.api.ui.component.Dialog;
    Import net.rim.device.api.ui.container.MainScreen;

    class ScrollingImageRecipe extends UiApplication {}

    private class ScrollingImageScreen extends form {}
    private static final int HORZ_SCROLL_FACTOR = 10;
    private static final int VERT_SCROLL_FACTOR = 10;

    Bitmap bitmap;
    int left = 0;
    high int = 0;
    int maxLeft = 0;
    maxTop int = 0;
           
    public ScrollingImageScreen() {}
    bitmap image = Bitmap.getBitmapResource ("test.png");
           
    If (bitmap == null) {}
    UiApplication.getUiApplication () .invokeLater (new Runnable() {}
    public void run() {}
    Dialog.Alert ("Failed to load image");
    System.Exit (0);
    }
    });
    return;
    }
               
    If (bitmap.getWidth () > Graphics.getScreenWidth ()) {}
    maxLeft = bitmap.getWidth () - Graphics.getScreenWidth ();
    }
               
    If (bitmap.getHeight () > Graphics.getScreenHeight ()) {}
    maxTop = bitmap.getHeight () - Graphics.getScreenHeight ();
    }
    }
           
    protected void paint (Graphics graphics) {}
    If (bitmap! = null) {}
    graphics.drawBitmap (0, 0, Graphics.getScreenWidth (), Graphics.getScreenHeight (),
    bitmap, left, top);
    }
    }
           
    protected boolean navigationMovement (int dx, int dy, int, int time status) {}
    left += (dx * HORZ_SCROLL_FACTOR);
    top += (dy * VERT_SCROLL_FACTOR);

    If (on the left< 0)="" left="">
    If (upper-< 0)="" top="">
    If (left > maxLeft) left = maxLeft;
    If (top > maxTop) top = maxTop;

    Invalidate();

    Returns true;
    }
    }

    Public Shared Sub main (String [] args) {}
    ScrollingImageRecipe app = new ScrollingImageRecipe();
    app.enterEventDispatcher ();
    }
       
    {ScrollingImageRecipe()}
    pushScreen (new ScrollingImageScreen());
    }

    }

    //-------------------------------

    Please be so kind to give me a solution for this issue.

    You can use a browserfield to display web content in your application.  Take a look at the browserfielddemo provided with the BlackBerry JDE for example

    If you ask how to connect to a web site, please see the httpdemo.

    This example shows how to create a scrolling image field.

    -Creates a scrolling Image field
    Article number: DB-00681

    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800345/...

  • Problem with a Bitmap image in a ButtonField (get a 104 NullPointerException error)

    Hi, I'm a beginner in programming BlackBerry Apps, well...

    I tried to create a simple ButtonField customized with a bitmap inside, but I constantly get an error 104 eception: NullPointerException, here is my code to field custom buttond.

    import net.rim.device.api.ui.component.ButtonField;import net.rim.device.api.ui.Graphics;import net.rim.device.api.system.Bitmap;
    
    public class CustomButtonField extends ButtonField{  
    
      private Bitmap imagen;
    
      CustomButtonField(Bitmap imagen, long style){
    
          super(style);     this.imagen = imagen;                     }
    
      public int getPreferredWidth(){
    
                    return 60;        }
    
      public int getPreferredHeight(){
    
          return 60;        }
    
     protected void paint(Graphics graphics) {
    
          graphics.drawBitmap(0, 0, imagen.getWidth(), imagen.getHeight(), imagen, 0, 0);   }
    
       protected void layout(int width, int height) {
    
          setExtent(getPreferredWidth(), getPreferredHeight());
    
        }  }
    
    import net.rim.device.api.ui.container.MainScreen;import net.rim.device.api.system.Bitmap;
    
    public class PruebaScreen extends MainScreen{    
    
      private CustomButtonField boton;
    
      PruebaScreen(){
    
          Bitmap imagen = Bitmap.getBitmapResource("res/img/icon.png");     boton = new CustomButtonField(imagen, 0);     add(boton);
    
      }}
    

    I suspect that my problem is due to the method of painting or the page layout, I don't know... I hope someone can help me, thank you very much in advance.

    Check if your getBitmapResource returns any non-null Bitmap image.  Specify the path correctly may take a few tries ("' / res/img/icon.png '," img/icon.png", etc.")

  • How fade in / Fade out bitmap image?

    Hello friends,

    I want to give fade in / hide a picture bitmap effect in my app. How can I achieve this?

    Thank you

    Use Graphics.setGlobalAlpha (int)

    with a value decremented/increment in object before draw image and Timer to invalidate the image.

  • scrolling problem large bitmap image

    City previous forums:

    Comments: comments
    scrolling problem large bitmap image
    Posted: Sep 28, 2007 14:47
     
    I want to scroll through a large bitmap image.i have read previous threads.i have added a null field before bitmap field. But the big picture scrolls, but shows an arrow down.
    Please help me.
    Thanks in advance.

    wang0043

    Messages: 12
    Join date: September 2007

    Re: image to large bitmap scrolling problem
    Posted the: October 1, 2007 03:35
     
    I have the same problem. After testing different ways using the BitmapField, I just changed paint the bitmap on the screen instead. More write the paint method and use drawbitmap to draw the bitmap to the screen. Track action wheelball to paint the bitmap can achieve the effect of view.

    Comments
    Re: image to large bitmap scrolling problem
    Posted the: 3 October 2007 18:10
     
    Can you guys post the code on how it's done?
    Thank you

    Comments: vicky
    Re: image to large bitmap scrolling problem
    Posted the: July 19, 2008 02:33
     
    Hello

    I get the same scrolling image problem. Can you please suggest some way

    thanx

    What kind of manager added the BitmapField to?  The support of the Manager there vertical or horizontal scrolling style defined?

    Here is an example of code that I use to show how to scroll through a screen image:

    Scrolling Image recipe

    The image of "test.png" is in the same folder as the source of java if you want to download that as well.

  • I'm looking for swatches in bitmap images

    Hi all

    I can't find the color chart in bitmap images, like finding objects to fill color

    Help would be appreciated.

    var mydoc = app.documents.item (0)

    var myobjects = mydoc.splineItems.everyItem () .getElements ();

    for (i = 0; i < myobjects.length; i ++) {}

    var myobject = myobjects [i];

    If {(myobject.fillColor.name=="FINISHING)"}

    myobject.itemLayer = mydoc.layers.item ("LASER");

    }

    }

    Thank you

    Hello

    ... or change this line:

    ...

    if ( myobject.graphics.count() &&

    ...

    Jarek

  • Does anyone has knowledge with the import of bitmap images that display perfectly similar to full screen &amp; small

    I created a file of projection for a cd-rom. In the project file, we have added buttons to display full-screen or return to the screen 800 x 600. I imported our company logo which is only available as a bitmap. In the flash program, I put across the 1200 dpi at reduced size logo. However, I noticed that the logo is horrible when scaled to small. But you click on the button to enlarge to full screen, the logo looks great. Flash seems to understand that big logo real size will be read better in full screen, but cannot manage the bitmap well when you scale to a smaller size. So I did a test where I saved the logo in Photoshop at the small size. It looks very small, but when you expand to full screen, the logo appears blurry. In other words, I don't get the best of 2 worlds. Is it possible to have a bitmap image appear visually crisp at full screen or smallscreen? I tried to save at different resolutions such as 500 dpi, 400 dpi and 300 dpi. 300A almost what I want, but seem sweet when you cut them in full screen.

    Depends on a lot of things. Have you tried the 'use smoothing' option in the import of bitmap window? A logo is also still vector exactly due to similar reasons. If you can recreate it in a vector format you wouldn't have problems.

    Another way to take is to calculate for the highest resolution at which the flash runs (usually 1920 x 1200) (very few people have higher resolution screens, and even 1920 x 1200 is a rare case, 1680 x 900 - more likely) and adapted the logo in Photoshop to this resolution.

    This could also be a bug in the version of Flash you use. Another option is to have 2 images to 800 x 600 and full screen and change them accordingly with ACE (you can detect if the player goes to fullscreen or not with ACE)

    But the most likely reason is that you have a bug in your version of Flash... 1200 dpi also seems too gigantic to purposes not printing, maybe the reason why you encounter the bug.

    Emil Georgiev - Flash and Web design

  • I get an "OLE" instead of a Bitmap image when you drag an image from Firefox to CorelDraw X 4, how do I prevent this?

    I get an "OLE" instead of a Bitmap image when you drag an image from Firefox to CorelDraw X 4, how do I prevent this?

    First, drag the image on the desktop, and drag it to Corel Draw. If your dragging directly from firefox to Corel Draw, only copied link.

  • How to convert the Bitmap Image in BlackBerry

    Hello

    In my application, I get the picture from the server. Now, I want to convert this Bitmap Image to display on the screen. For this I use below codes. But it doesn't give me the same image does not mean with the clarity and the exact size. He's smaller than the picture.

    I used the codes below:

    private Bitmap getBitmapFromImg(Image img) {
            Bitmap bmp = null;
            try {
                Logger.out(TAG, "It is inside the the image conversion        " +img);
                Image image = Image.createImage(img);
                byte[] data = BMPGenerator.encodeBMP(image);
                Logger.out(TAG, "It is inside the the image conversion---333333333"+data);
                bmp = Bitmap.createBitmapFromBytes(data, 0, data.length, 1);
                } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return bmp;
            // TODO Auto-generated method stub
        }
    

    Here is the BMPGenerator class:

    public final class BMPGenerator {
    
            /**
             * @param image
             * @return
             * @throws IOException
             * @see {@link #encodeBMP(int[], int, int)}
             */
            public static byte[] encodeBMP(Image image) throws IOException {
                    int width = image.getWidth();
                    int height = image.getHeight();
                    int[] rgb = new int[height * width];
                    image.getRGB(rgb, 0, width, 0, 0, width, height);
                    return encodeBMP(rgb, width, height);
            }
    
            /**
             * A self-contained BMP generator, which takes a byte array (without any unusual
             * offsets) extracted from an {@link Image}. The target platform is J2ME. You may
             * wish to use the convenience method {@link #encodeBMP(Image)} instead of this.
             * 

    * A BMP file consists of 4 parts:- *

      *
    • header
    • *
    • information header
    • *
    • optional palette
    • *
    • image data
    • *
    * At this time only 24 bit uncompressed BMPs with Windows V3 headers can be created. * Future releases may become much more space-efficient, but will most likely be * ditched in favour of a PNG generator. * * @param rgb * @param width * @param height * @return * @throws IOException * @see http://en.wikipedia.org/wiki/Windows_bitmap */ public static byte[] encodeBMP(int[] rgb, int width, int height) throws IOException { int pad = (4 - (width % 4)) % 4; // the size of the BMP file in bytes int size = 14 + 40 + height * (pad + width * 3); ByteArrayOutputStream bytes = new ByteArrayOutputStream(size); DataOutputStream stream = new DataOutputStream(bytes); // HEADER // the magic number used to identify the BMP file: 0x42 0x4D stream.writeByte(0x42); stream.writeByte(0x4D); stream.writeInt(swapEndian(size)); // reserved stream.writeInt(0); // the offset, i.e. starting address of the bitmap data stream.writeInt(swapEndian(14 + 40)); // INFORMATION HEADER (Windows V3 header) // the size of this header (40 bytes) stream.writeInt(swapEndian(40)); // the bitmap width in pixels (signed integer). stream.writeInt(swapEndian(width)); // the bitmap height in pixels (signed integer). stream.writeInt(swapEndian(height)); // the number of colour planes being used. Must be set to 1. stream.writeShort(swapEndian((short) 1)); // the number of bits per pixel, which is the colour depth of the image. stream.writeShort(swapEndian((short) 24)); // the compression method being used. stream.writeInt(0); // image size. The size of the raw bitmap data. 0 is valid for uncompressed. stream.writeInt(0); // the horizontal resolution of the image. (pixel per meter, signed integer) stream.writeInt(0); // the vertical resolution of the image. (pixel per meter, signed integer) stream.writeInt(0); // the number of colours in the colour palette, or 0 to default to 2n. stream.writeInt(0); // the number of important colours used, or 0 when every colour is important; // generally ignored. stream.writeInt(0); // PALETTE // none for 24 bit depth // IMAGE DATA // starting in the bottom left, working right and then up // a series of 3 bytes per pixel in the order B G R. for (int j = height - 1; j >= 0; j--) { for (int i = 0; i < width; i++) { int val = rgb[i + width * j]; stream.writeByte(val & 0x000000FF); stream.writeByte((val >>> 8) & 0x000000FF); stream.writeByte((val >>> 16) & 0x000000FF); } // number of bytes in each row must be padded to multiple of 4 for (int i = 0; i < pad; i++) { stream.writeByte(0); } } byte[] out = bytes.toByteArray(); bytes.close(); // quick consistency check if (out.length != size) throw new RuntimeException("bad math"); return out; } /** * Swap the Endian-ness of a 32 bit integer. * * @param value * @return */ private static int swapEndian(int value) { int b1 = value & 0xff; int b2 = (value >> 8) & 0xff; int b3 = (value >> 16) & 0xff; int b4 = (value >> 24) & 0xff; return b1 << 24 | b2 << 16 | b3 << 8 | b4 << 0; } /** * Swap the Endian-ness of a 16 bit integer. * * @param value * @return */ private static short swapEndian(short value) { int b1 = value & 0xff; int b2 = (value >> 8) & 0xff; return (short) (b1 << 8 | b2 << 0); }

    Where an error in my code? Is there another way to do the same thing?

    Why you want to use a bmp image?
    You can just use png, jpg or whatever of the original image is.
    If there is a situation where you need the bitmap image call http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/system/EncodedImage.html#getBi...

  • How to change the bitmap image in blackberry

    Hello

    1. work on the version of BB storm (9500/9530 Simulator) is v4.7.0.75
    2 opportunity BB JDE 4.7
    3. the request is:

    I display a bitmap image by using the drawBitmap method. now I want to select a portion of the bitmap, and then I need to cut & paste the part somewhere in the screen (MSPaint we have option 'Select').

    is there any method that will make the similar operation (or) any idea to accomplish this in blackberry.

    Thank you

    Sendhil Kumar V

    Take a look at this thread and refers to the J2ME code:

    http://supportforums.BlackBerry.com/Rim/Board/message?board.ID=java_dev&message.ID=24929

    The 'trick' is getARGB() and setARGB().  As long as you check out relevant Bitmap Moose ARGB values, you should be able to create a new Bitmap.  That said, I never did.  Let us know how you go.

  • Change the images of the app

    Hey there, sorry if this has been asked before:
    I downloaded the new images of my app and removed the 'old' because I changed my user interface. Everything has been approved but the first image shown (beside the description) is still there. When it is selected (for more pictures), it shows all new, which is fine, but I would change the original.

    An example can be seen here: http://appworld.blackberry.com/webstore/content/26864?lang=en

    Now if it's just a matter of not to wait for the appworld update, then I apologize.

    My bad, looks like I just had to give it time.

  • PaintBackgound of screen does not paint my bitmap image, but don't paint screen?

    There is something I don't understand with the paint and screen paintBackground.

    I am trying to add a background (Bitmap) image to my final class that extends screen and add a VerticalFieldManager on top of the background image.

    Screen.Paint painted my Bitmap, but hides the VerticalFieldManager:

    protected void paint(Graphics graphics) {
      graphics.clear();
      graphics.drawBitmap(0, 0, deviceWidth, deviceHeight, bgBitmap, 0, 0);
      super.paint(graphics);
    }
    

    However, Screen.paintBackground does not paint my Bitmap or my VerticalFieldManager, and I have a blank white screen?

    protected void paintBackground(Graphics graphics) {
      graphics.clear();
      graphics.drawBitmap(0, 0, deviceWidth, deviceHeight, bgBitmap, 0, 0);
      super.paintBackground(graphics);
    }
    

    The API of the playback screen, I thought paintBackground was the right way to achieve this?

    It's an old bug in BB - do not trust Screen.paintBackground (especially MainScreen.paintBackground!). PaintBackground of your Manager is a much better place for it (I know it is not documented, but if you read the Screen.paintBackground you will see it's substitute Field.paintBackground.).

  • Cannot select more than one bitmap image in desktop Animate

    I can't select more than one bitmap image in desktop Animate. Always select the same object, what should I do?

    I guess these bitmaps are on the scene. They are all on the same layer? Who is always selected is large and, perhaps, on top of all the others?

    If the bitmaps are all on one layer, you can separate each in separate layers. Once you do this, you can lock / unlock layers individually so that you can work with one image at a time.

  • No color for the Bitmap Images after upgrade

    I've updated to ID 2015.4 (Build 11.4.0.90) and now all my bitmap images that have a color not found in the documents. Export a PDF images work as expected. Overview of images of gray as expected.

    What is a change or a bug regarding bitmaps?

    This is a bug. The solution is to turn on view > overprint preview.

    Impossible to transparent color TIFF in InDesign

Maybe you are looking for