我使用以下代码覆盖2位图:
private Bitmap overlay(Bitmap bmp1, Bitmap bmp2) {
Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
Canvas canvas = new Canvas(bmOverlay);
canvas.drawBitmap(bmp1, new Matrix(), null);
canvas.drawBitmap(bmp2, new Matrix(), null);
return bmOverlay;
}
它的作用如下:将第二个位图放在左上角的第一个位图的顶部。
我的问题是如何将第二个位图放在中间底部?谢谢:))
答案 0 :(得分:0)
试试这个:
private Bitmap overlay(Bitmap bmp1, Bitmap bmp2) {
Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
Canvas canvas = new Canvas(bmOverlay);
canvas.drawBitmap(bmp1, new Matrix(), null);
int centerX = (int) bmp1.getWidth()/2;
int centerY = (int) bmp1.getHeight()/2;
canvas.drawBitmap(bmp2, centerX, centerY, null);
return bmOverlay;
}