开发者

Android: building a composite image

开发者 https://www.devze.com 2023-03-14 18:44 出处:网络
Im porting an app from Flex to Android and wondering about how to build a composite image and display it.

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' av开发者_如何学Goailable here though its a bit dated.

Suggestions on where to start?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消