Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: building a composite image

Tags:

android

image

Im porting an app from Flex to Android and wondering about how to build a composite image and display it.

Specifically I have a map (PNG or JPG) of a house and Im placing different markers in various locations. I've implemented this in HTML using DIV and in Flex using a canvas. Each marker has an X,Y pair based on the original size of the image. Ideally I'd like to display the image, place the markers and then support resize, drag (of the image, not the markers), etc.

There is info about 'multi-touch' available here though its a bit dated.

Suggestions on where to start?

like image 375
ethrbunny Avatar asked Feb 24 '23 19:02

ethrbunny


1 Answers

You have to watch out for non-mutable bitmaps. When you load your bitmap, you have to create a copy which will be mutable. Then just apply your overlay using a Canvas.

     Bitmap tempBitmap = BitmapFactory.decodeResource(getResources(), R.id.background, options);
     Bitmap overlay = BitmapFactory.decodeResource(getResources(), R.id.overlay, options);

     Bitmap finalBitmap = Bitmap.createBitmap(tempBitmap.getWidth(), tempBitmap.getHeight(), tempBitmap.getConfig());

     Canvas canvas = new Canvas(finalBitmap);

     canvas.drawBitmap(tempBitmap, new Matrix(), null);
     canvas.drawBitmap(badge, new Matrix(), null);

     // finalBitmap will contain your background and its overlay

-I_Artist

like image 133
MikeWallaceDev Avatar answered Mar 07 '23 13:03

MikeWallaceDev