I've got a things to do with android, so, I have 2 images, 1. image from camera 2. another image from somewhere
so what I want to achieve is how to combine those image into 1 image, but it's overlapping (just like watermarking the image), the 2nd image should be scaled first into the size of the 1st image(camera) - so they have same dimension, then if the 2nd image pixel is black, don't combine it (so the black means transparent color - on 2nd image)
do you know what is the best way achieve this, can I do this with xor or bitwise?
Any reference or sample code would be really really much appreciate.
Thanks guys,
For overlaying two bitmaps:
public static Bitmap overlay(Bitmap bmp1, Bitmap bmp2) {
Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
Canvas canvas = new Canvas(bmOverlay);
canvas.drawBitmap(bmp1, new Matrix(), null);
canvas.drawBitmap(bmp2, 0, 0, null);
return bmOverlay;
}
And for scaling one first you should check out createScaledBitmap, e.g:
Bitmap scaledBitmap = Bitmap.createScaledBitmap(src, dstWidth, dstHeight, filter);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With