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 Developer
Posts: 36
Registered: ‎11-23-2009
My Device: Not Specified

Problem developing a small map-like application

Hello all,

I'm trying to develop a small map-like application for blackberry. I need to know how can I position a small image onto another much larger image.I would like to stack bitmaps on top of each other.

The larger image is like a map, I'll need to use the smaller image to pin point a specific position on the map. So the smaller image should overlay on top of the larger image.  At the same time, I'll need to move the map around, and the smaller image should follow that position on the map.

Does anyone know if there is a specific API for this problem?

Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: Problem developing a small map-like application

Create a BitmapField using one Bitmap and in BitmapField paint method draw the other bitmap(pin image) to specific location using co-ordinates.


Use Search. "Accept Solution" If the problem is resolved.
New Developer
Posts: 36
Registered: ‎11-23-2009
My Device: Not Specified

Re: Problem developing a small map-like application

Thank you for your help, I'm new to Blackberry developing, do you know if there is place where I can find sample code for the method you mentioned?  

New Developer
Posts: 2
Registered: ‎11-09-2009
My Device: Not Specified

Re: Problem developing a small map-like application

I wrote this according to your method, however, It printed out a blank screen.  Can you tell me what's wrong with my code?

 

 

 

 

 int x = 0;
  int y = 0;
  int left = 0;
  int top = 0;
  int maxLeft = 0;
  int maxTop = 0;
  String map1 = "111.png";
  String map2 = "00000.png";
  Bitmap bitmap1 = Bitmap.getBitmapResource(map1);
  Bitmap bitmap2 = Bitmap.getBitmapResource(map2);
  
  public GetImages (){
   
   
   BitmapField bitmapField = new BitmapField(bitmap1){
    protected void paint(Graphics graphics ) {
     graphics.drawBitmap(0, 0, bitmap1.getWidth(),bitmap1.getHeight(), bitmap2, left, top);
    }
   };
   this.add(bitmapField);
  
   

 

 

 

Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: Problem developing a small map-like application

[ Edited ]

Something like this...

 

 

        BitmapField bmp1 = new BitmapField(Bitmap.getBitmapResource("1.PNG"))
        {
            Bitmap nnimage = Bitmap.getBitmapResource("2.PNG");
            public void paint(Graphics g)
            {
                super.paint(g);
                g.drawBitmap(5,5,25,25,nnimage,0,0);
            }
        };
        add(bmp1);

PS: was in edit mode when the other user posted the solution.


Use Search. "Accept Solution" If the problem is resolved.
New Developer
Posts: 2
Registered: ‎11-09-2009
My Device: Not Specified

Re: Problem developing a small map-like application

It works, thank you.   I'm able to paint the small image on top of the larger image, but now I lost the ability to move the larger image around.

 

What I'm trying to do is to allow user to move the larger image around and see different section of the image, at the same time, the small image should stay at specific location on the larger image.  Like a POI on the Google map. 

 

Now, when I try to move the larger image, I get a error screen.

 

JVM Error 04