Reputation: 1162
How can i merge two different images as one. Also i need to merge the second image at a particular point on the first image. Is it posible in android??
Upvotes: 8
Views: 1699
Reputation: 9599
This should work:
Upvotes: 2
Reputation: 10955
I guess this function can help you:
private Bitmap mergeBitmap(Bitmap src, Bitmap watermark) {
if (src == null) {
return null;
}
int w = src.getWidth();
int h = src.getHeight();
Bitmap newb = Bitmap.createBitmap(w, h, Config.ARGB_8888);
Canvas cv = new Canvas(newb);
// draw src into canvas
cv.drawBitmap(src, 0, 0, null);
// draw watermark into
cv.drawBitmap(watermark, null, new Rect(9, 25, 154, 245), null);
// save all clip
cv.save(Canvas.ALL_SAVE_FLAG);
// store
cv.restore();
return newb;
}
It draws the water mark onto "src" at specific Rect.
Upvotes: 1