开发者

Combining 2 Images overlayed

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 l开发者_开发百科ike 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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜