This is close at the corner of the image.
Paint. setxfermode (New porterduxfermode (mode. src_in ));
After a long struggle, I don't know what the setxfermode is. Later I read the official documents and read some materials to learn about them.
Paint. setxfermode (New porterduxfermode (mode. src_in); more powerful
You can modify the xfermode of paint to influence the way to draw new colors on existing images of the canvas.
Normally, plotting on an existing image adds a new shape to it. If the new paint is completely opaque, It will completely block the lower paint; if it is partially transparent, it will be stained with the following color.
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. 16 Porter-Duff rule source code
public class PorterDuff { // these value must match their native equivalents. See SkPorterDuff.h public enum Mode { /** [0, 0] */ CLEAR (0), /** [Sa, Sc] */ SRC (1), /** [Da, Dc] */ DST (2), /** [Sa + (1 - Sa)*Da, Rc = Sc + (1 - Sa)*Dc] */ SRC_OVER (3), /** [Sa + (1 - Sa)*Da, Rc = Dc + (1 - Da)*Sc] */ DST_OVER (4), /** [Sa * Da, Sc * Da] */ SRC_IN (5), /** [Sa * Da, Sa * Dc] */ DST_IN (6), /** [Sa * (1 - Da), Sc * (1 - Da)] */ SRC_OUT (7), /** [Da * (1 - Sa), Dc * (1 - Sa)] */ DST_OUT (8), /** [Da, Sc * Da + (1 - Sa) * Dc] */ SRC_ATOP (9), /** [Sa, Sa * Dc + Sc * (1 - Da)] */ DST_ATOP (10), /** [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + (1 - Sa) * Dc] */ XOR (11), /** [Sa + Da - Sa*Da, Sc*(1 - Da) + Dc*(1 - Sa) + min(Sc, Dc)] */ DARKEN (12), /** [Sa + Da - Sa*Da, Sc*(1 - Da) + Dc*(1 - Sa) + max(Sc, Dc)] */ LIGHTEN (13), /** [Sa * Da, Sc * Dc] */ MULTIPLY (14), /** [Sa + Da - Sa * Da, Sc + Dc - Sc * Dc] */ SCREEN (15); Mode(int nativeInt) { this.nativeInt = nativeInt; } final int nativeInt; }
I wrote a method for testing, when they go to different enumerations, the custom graph display is different/* bitmap source image * roundpx rounded corner degree * mode porterduff Enumeration type value */
Public static bitmap getroundedcornerbitmap (Bitmap bitmap, float roundpx, mode) {bitmap output = bitmap. createbitmap (bitmap. getwidth (), bitmap. getheight (), config. argb_4444); canvas = new canvas (output); Final int color = 0xff0000242; Final paint = new paint (); Final rect = new rect (0, 0, bitmap. getwidth (), bitmap. getheight (); Final rectf = new rectf (rect); paint. setantialias (true); canvas. drawargb (0, 0, 0, 0); paint. setcolor (color); canvas. drawroundrect (rectf, roundpx, roundpx, paint); // paint. setxfermode (New porterduduxfermode (mode. src_in); // multiply multi-layer shadow paint. setxfermode (New porterduduxfermode (mode); canvas. drawbitmap (bitmap, rect, rect, paint); Return output ;}
Imageview1.setimagebitmap (imgutil. getmodebitmap (Bt. getbitmap (), mode. Values () [integer. parseint (Num)]);
The front is the source image, and the back is dst_over.
You will know what it means when you try it.