Composite operations in Android Canvas

后端 未结 3 2145
青春惊慌失措
青春惊慌失措 2021-02-09 07:18

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:56

    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.

提交回复
热议问题