Package Com.example.administrator.test.Five.Second;
Import Android.content.Context;
Import Android.graphics.Bitmap;
Import Android.graphics.BitmapFactory;
Import Android.graphics.Canvas;
Import Android.graphics.Color;
Import Android.graphics.Paint;
Import Android.graphics.PorterDuff;
Import Android.graphics.PorterDuffXfermode;
Import Android.util.AttributeSet;
Import Android.view.View;
Import COM.EXAMPLE.ADMINISTRATOR.TEST.R;
/**
* Created by Administrator on 2017/7/21.
*/
public class Anomalousphotoview extends View {
Private Bitmap Bmpcat;
Private Bitmap Bmpmask;
Private Bitmap Bmpresult;
Canvas C_bmpcat;
Canvas C_bmpmask;
Canvas C_result;
private paint paint;
private static final int offset=10;
Public Anomalousphotoview (context context, AttributeSet Attrs) {
Super (CONTEXT,ATTRS);
bmpcat= Bitmapfactory.decoderesource (Context.getresources (), R.drawable.luoluo);
bmpmask= Bitmap.createbitmap (Bmpcat.getwidth (), Bmpcat.getheight (), Bitmap.Config.ARGB_8888);
C_bmpmask=new Canvas (Bmpmask);
Paint=new Paint (Paint.anti_alias_flag);
}
@Override
protected void OnDraw (canvas canvas) {
Super.ondraw (canvas);
int Id=canvas.savelayer (0,0,bmpcat.getwidth (), Bmpcat.getheight (), Null,canvas.all_save_flag);
Canvas.drawbitmap (Bmpcat,0,0,null);
Paint.setcolor (Color.Blue);
C_bmpmask.drawcircle (Bmpcat.getwidth ()/2,bmpcat.getheight ()/2,200,paint);
Paint.setxfermode (New Porterduffxfermode (PorterDuff.Mode.DST_IN));
Canvas.drawcircle (100,100,100,paint);
Canvas.drawbitmap (Bmpmask,0,0,paint);
Canvas.restoretocount (ID);
}
}
Android's simple round head