Android's simple round head

Source: Internet
Author: User

Package Com.example.administrator.test.Five.Second;

Import Android.content.Context;
Import Android.util.AttributeSet;
Import Android.view.View;


* 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) {

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);

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

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.