Blending pixels from Two Bitmaps

前端 未结 2 1960
庸人自扰
庸人自扰 2020-12-24 03:17

I\'m beating my head against a wall here, and I\'m fairly certain I\'m doing something stupid, so time to make my stupidity public.

I\'m trying to take two images, b

2条回答
  •  清酒与你
    2020-12-24 04:10

    Simple overlay you can do this way (for simplicity it is supposed that bmp1 is equal or bigger than bmp2):

    private Bitmap bitmapOverlay(Bitmap bmp1, Bitmap bmp2) 
    { 
        Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig()); 
        Canvas canvas = new Canvas(bmOverlay); 
        canvas.drawBitmap(bmp1, 0, 0, null);
        canvas.drawBitmap(bmp2, 0, 0, null);
        return bmOverlay; 
    } 
    

    For more complex blending algorithms, maybe you can help yourself with some available Bitmap/Canvas functions.

提交回复
热议问题