标签:android mod mask attr 简易 rgb nal import circle
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 mod mask attr 简易 rgb nal import circle
原文地址:http://www.cnblogs.com/lonikitave/p/7229222.html