Android Color Rendering (ix) Porterduff and Xfermode detailed

Source: Internet
Author: User

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android Color Rendering (ix) Porterduff and Xfermode detailed

All subclasses of shader, except Composeshader, have been mentioned before, Composeshader (combined rendering), because of the need to construct Composeshader Porterduffxfermode or Porterduff.mode as a parameter, so here is a detailed understanding of the role of these two classes, which will be of great help to the subsequent drawing:

Add a bit of knowledge before you talk about specific use, which is the origin of Proterduff:

Believe that most people see this proterduff Word is very strange, it is swollen what a meaning, and then use Youdao Ah, Jinshan AH began to translate, but the translation software given the results are definitely still proterduff or "not found."

This is God horse situation? Because Proterduff is a combination of two names: Tomas Proter and Tom Duff. They were the first large-scale figures to present the concept of graphic blending on siggraph. interested children's boots can be self-checking and in-depth understanding, there is no longer to do too much description.

Using Proterbuff.mode we can complete any 2D image measurement operations, such as the eraser effect in the graffiti application, draw a variety of custom progress, and so very powerful effect, below please see the specific introduction:

1. Xfermode:

There are three subcategories of Xfermode:

avoidxfermode Specifies a color and tolerance, forcing paint to avoid drawing on it (or just drawing on it).

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

Porterduffxfermode This is a very powerful conversion mode, using it, you can use any of the 16 porter-duff rules of the image composition to control how paint interacts with existing canvas images.

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

[Java]View PlainCopy
    1. Avoidxfermode avoid = new Avoidxfermode (Color.Blue, Avoidxfermode.mode.    AVOID);  Borderpen.setxfermode (avoid);


2.PorterDuff:

First look (from Apidemos/graphics/xfermodes)

From the above we can see that Porterduff.mode is an enumeration class with a total of 16 enumeration values:

1.porterduff.mode.clear

The drawing is not submitted to the canvas.
2.porterduff.mode.src

Show Top Draw picture
3.porterduff.mode.dst

Show Lower drawing pictures
4.porterduff.mode.src_over

Normal drawing shows that the upper and lower layers are drawn with overlapping covers.
5.porterduff.mode.dst_over

The upper and lower layers are displayed. The lower level is shown on the home.
6.porterduff.mode.src_in

Draw the intersection of two layers. Displays the upper layer.
7.porterduff.mode.dst_in

Draw the intersection of two layers. Displays the lower layer.
8.porterduff.mode.src_out

Draw the non-intersecting portion of the upper layer.
9.porterduff.mode.dst_out

Remove the layer to draw the non-intersecting part.
10.porterduff.mode.src_atop

Remove the non-intersecting part of the layer from the upper intersection section
11.porterduff.mode.dst_atop

Take the upper non-intersecting part and the lower part of the intersection
12.porterduff.mode.xor

XOR: Remove the two Layer intersection section
13.porterduff.mode.darken

Take two layers of all areas, the intersection part of the color deepened
14.porterduff.mode.lighten

take two layers all, light the intersection part color
15.porterduff.mode.multiply

Take two layer intersection part overlay color
16.porterduff.mode.screen

Take two layers of all areas, the intersection part becomes transparent color

Android Color Rendering (ix) Porterduff and Xfermode detailed

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.