与code问题两幅图像中的Andr​​oid结合? [英] problem with code to combine two images in android?

查看:173
本文介绍了与code问题两幅图像中的Andr​​oid结合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面的code表示将两个图像。

i am using the below code for combining two images.

    Bitmap pic = BitmapFactory.decodeResource(getResources(), R.drawable.me);
    Bitmap map = BitmapFactory.decodeResource(getResources(), R.drawable.static);
    Canvas comboImage = new Canvas(map);
    Bitmap out1 = null ;
    comboImage.setBitmap(out1);
    comboImage.drawBitmap(pic, 600, 350, null);

我假设的,我可以使用位图OUT1获取最终图像。但comboImage.setBitmap(OUT1);'线是导致飞机坠毁。没有这条线我不能够看到任何图像。我怎样才能得到最终的组合图像?

i am assuming that the i can use the bitmap out1 for getting the final image. but 'comboImage.setBitmap(out1);' line is causing a crash. without this line i am not able to see any images. how can i get the final combined image?

推荐答案

如果您希望最终图像 OUT1 ,你会做这样的:

If you want the final image to be out1, you would do it like this:

Bitmap out1 = Bitmap.createBitmap(...);
Canvas comboImage = new Canvas(out1);
comboImage.drawBitmap(map, ...);
comboImage.drawBitmap(pic, ...);

OUT1 然后将合并图像

这篇关于与code问题两幅图像中的Andr​​oid结合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆