[Android] setXfermode attribute

Source: Internet
Author: User

1. The following Xfermode subclass can change this behavior:

AvoidXfermode specifies a color and a tolerance, forcing Paint to avoid plotting on it (or drawing only on it ).

PixelXorXfermode applies a simple pixel XOR operation when the existing color is overwritten.

Porterduxfermode is a very powerful conversion mode. With this mode, you can use any of the 16 Porter-Duff rules for image synthesis to control how Paint interacts with existing Canvas images.

To apply the conversion mode, you can use the setXferMode method as follows:

AvoidXfermode avoid = new AvoidXfermode (Color. BLUE, 10, AvoidXfermode. Mode. AVOID); borderPen. setXfermode (avoid );

 

2. Porter-Duff:

 


3.16 Porter-Duff rules

1. PorterDuff. Mode. CLEAR

The drawn image is not submitted to the canvas.
2. PorterDuff. Mode. SRC

Show upper-layer picture
3. PorterDuff. Mode. DST

Show lower layer picture
4. PorterDuff. Mode. SRC_OVER

Normal painting display, stacked on the upper and lower layers.
5. PorterDuff. Mode. DST_OVER

The upper and lower layers are displayed. The lower layer is displayed on top.
6. PorterDuff. Mode. SRC_IN

Draw the intersection of two layers. The upper layer is displayed.
7. PorterDuff. Mode. DST_IN

Draw the intersection of two layers. The lower layer is displayed.
8. PorterDuff. Mode. SRC_OUT

Draw non-intersection parts from the upper layer.
9. PorterDuff. Mode. DST_OUT

Draws non-intersection parts from the lower layer.
10. PorterDuff. Mode. SRC_ATOP

Take the lower-layer non-intersection part and the upper-layer intersection part
11. PorterDuff. Mode. DST_ATOP

Take the non-intersection part of the upper layer and the intersection part of the lower layer
12. PorterDuff. Mode. XOR


13. PorterDuff. Mode. DARKEN


14. PorterDuff. Mode. LIGHTEN


15. PorterDuff. Mode. MULTIPLY


16. PorterDuff. Mode. SCREEN

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.