用另一个图像覆盖画布图像android

2023-12-15

我的屏幕上显示了平面图的图像,我的问题是如何在其上叠加另一张图像。

查看来自另一个线程的图像,我在其中询问了如何here

/**
 * floor plan drawing.
 *
 * @param canvas the canvas on which the background will be drawn
 */
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    Bitmap temp = BitmapFactory.decodeResource(getResources(), R.drawable.floorplan);
    image= Bitmap.createScaledBitmap(temp, canvas.getWidth(), canvas.getHeight(), true);
    canvas.drawBitmap(image, 0, 0, null);

}

将第二张图片添加到第一张图片上怎么样?

@Override
protected void onDraw(Canvas canvas)
{
    super.onDraw(canvas);
    Bitmap temp = BitmapFactory.decodeResource(getResources(), R.drawable.floorplan);
    image = Bitmap.createScaledBitmap(temp, canvas.getWidth(), canvas.getHeight(), true);
    canvas.drawBitmap(image, 0, 0, null);

    Bitmap over = BitmapFactory.decodeResource(getResources(), R.drawable.overlay);
    image = Bitmap.createScaledBitmap(over, canvas.getWidth(), canvas.getHeight(), true);
    canvas.drawBitmap(image, 0, 0, null);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

用另一个图像覆盖画布图像android 的相关文章

随机推荐