Android developed a method to combine two images into one

  • 2021-01-14 06:39:58
  • OfStack

This article illustrates the method developed by Android to merge two images into one. To share with you for your reference, as follows:

The main operating codes are as follows:


private Bitmap mergeBitmap(Bitmap firstBitmap, Bitmap secondBitmap) {
  Bitmap bitmap = Bitmap.createBitmap(firstBitmap.getWidth(), firstBitmap.getHeight(),firstBitmap.getConfig());
  Canvas canvas = new Canvas(bitmap);
  canvas.drawBitmap(firstBitmap, new Matrix(), null);
  canvas.drawBitmap(secondBitmap, 0, 0, null);
  return bitmap;
}

For more information about Android graphics and image manipulation, readers interested in Android graphics and image processing techniques can check out the special features of this site: Android graphics and image processing skills summary and Android photography and image processing skills summary

I hope this article is helpful to Android program design.


Related articles: