Composite operations in Android Canvas

后端 未结 3 636
予麋鹿
予麋鹿 2021-02-09 07:21

I\'m just starting with Android development and I\'m coming from JavaScript/HTML world so I\'m currently investigating the possibilities of the Android SDK.

The HTML 5 c

3条回答
  •  情书的邮戳
    2021-02-09 07:54

    Composition is handled by drawing on a Canvas with a Paint that uses a PorterDuffXfermode.

    Paint p=new Paint();
    p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DARKEN));
    canvas.drawBitmap(bitmap, 0, 0, p);
    

    See here for more info. I also managed to override onPaint so that we can apply this composition to elements that draw themeselves.

提交回复
热议问题