Skip to content

Instantly share code, notes, and snippets.

@sunwicked
Created July 12, 2013 10:03
Show Gist options
  • Save sunwicked/5983305 to your computer and use it in GitHub Desktop.
Save sunwicked/5983305 to your computer and use it in GitHub Desktop.
A small snippet for overlapping images and merging them into one. Adjust size and position of bitmap as you want
public Bitmap overlay(Bitmap baseBitmap, Bitmap bmp2) {
Rect dst = new Rect();
final Bitmap bitmapMan = Bitmap.createBitmap(baseBitmap.getWidth(),
baseBitmap.getHeight(), baseBitmap.getConfig());
final Canvas canvas = new Canvas(bitmapMan);
canvas.drawBitmap(baseBitmap, new Matrix(), null);
dst.set(bitmapMan.getWidth() / 4, bitmapMan.getHeight() / 4,
bitmapMan.getWidth() * 3 / 4, bitmapMan.getHeight() * 3 / 4);
canvas.drawBitmap(bmp2, null, dst, null);
return bitmapMan;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment