以下是我用来重叠两张图片的代码。
public static Bitmap overlay(String patho,String patht) {
Bitmap bmp1= BitmapFactory.decodeFile(patho);
Bitmap bmp2= BitmapFactory.decodeFile(patht);
Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
Canvas canvas = new Canvas(bmOverlay);
Matrix m=new Matrix();
canvas.drawBitmap(bmp1, m, null);
canvas.drawBitmap(bmp2, m,null);
return bmOverlay;
}
使用上面的代码片段,我可以轻松地合并两个图像或将它们重叠在一起。以下是我实际想要实现的目标: