Skip to content

Instantly share code, notes, and snippets.

@jingle1267
Created July 27, 2014 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jingle1267/42ba5992e0e5d4ab773b to your computer and use it in GitHub Desktop.
Save jingle1267/42ba5992e0e5d4ab773b to your computer and use it in GitHub Desktop.
blog_irregular_shapes_part_1
public Bitmap combineImages(Bitmap bgd, Bitmap fg) {
Bitmap bmp;
int width = bgd.getWidth() > fg.getWidth() ?
bgd.getWidth() : fg.getWidth();
int height = bgd.getHeight() > fg.getHeight() ?
bgd.getHeight() : fg.getHeight();
bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Paint paint = new Paint();
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
Canvas canvas = new Canvas(bmp);
canvas.drawBitmap(bgd, 0, 0, null);
canvas.drawBitmap(fg, 0, 0, paint);
return bmp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment