合成兩張圖片,上下疊加的效果: ...
合成兩張圖片,上下疊加的效果:
/**
* 把兩個點陣圖覆蓋合成為一個點陣圖,以底層點陣圖的長寬為基準
*
* @param backBitmap 在底部的點陣圖
* @param frontBitmap 蓋在上面的點陣圖
* @return
*/
public static Bitmap mergeBitmap(Bitmap backBitmap, Bitmap frontBitmap) {
if (backBitmap == null || backBitmap.isRecycled()
|| frontBitmap == null || frontBitmap.isRecycled()) {
return null;
}
Bitmap bitmap = backBitmap.copy(Bitmap.Config.ARGB_8888, true);
Canvas canvas = new Canvas(bitmap);
Rect baseRect = new Rect(0, 0, backBitmap.getWidth(), backBitmap.getHeight());
Rect frontRect = new Rect(0, 0, frontBitmap.getWidth(), frontBitmap.getHeight());
canvas.drawBitmap(frontBitmap, frontRect, baseRect, null);
return bitmap;
}