你必須注意不可變的位圖。當你加載你的位圖時,你必須創建一個可變的副本。然後,只需使用Canvas應用覆蓋。
Bitmap tempBitmap = BitmapFactory.decodeResource(getResources(), R.id.background, options);
Bitmap overlay = BitmapFactory.decodeResource(getResources(), R.id.overlay, options);
Bitmap finalBitmap = Bitmap.createBitmap(tempBitmap.getWidth(), tempBitmap.getHeight(), tempBitmap.getConfig());
Canvas canvas = new Canvas(finalBitmap);
canvas.drawBitmap(tempBitmap, new Matrix(), null);
canvas.drawBitmap(badge, new Matrix(), null);
// finalBitmap will contain your background and its overlay
-I_Artist
是否可以指定一個x,y座標「頂部」原來的放置圖像? – ethrbunny
對矩陣應用posttranslate –