I think this example will definitely help you overlay a transparent image on top of another image. This was made possible by drawing images on canvas and returning the bitmap.
More details or download the demo here
private Bitmap createSingleImageFromMultipleImages(Bitmap firstImage, Bitmap secondImage){ Bitmap result = Bitmap.createBitmap(firstImage.getWidth(), firstImage.getHeight(), firstImage.getConfig()); Canvas canvas = new Canvas(result); canvas.drawBitmap(firstImage, 0f, 0f, null); canvas.drawBitmap(secondImage, 10, 10, null); return result; }
and call the above function at the click of a button and transfer the two images to our function, as shown below.
public void buttonMerge(View view) { Bitmap bigImage = BitmapFactory.decodeResource(getResources(), R.drawable.img1); Bitmap smallImage = BitmapFactory.decodeResource(getResources(), R.drawable.img2); Bitmap mergedImages = createSingleImageFromMultipleImages(bigImage, smallImage); img.setImageBitmap(mergedImages); }
For more than two images, you can follow this link , how to merge several images programmatically on android .
Daniel Nyamasyo Dec 19 '16 at 12:53 on 2016-12-19 12:53
source share