Android 模糊遮罩滤镜(BlurMaskFilter)

Alpha 滤镜处理

MaskFilter

  • (1).模糊遮罩滤镜(BlurMaskFilter)
  • (2).浮雕遮罩滤镜(EmbossMaskFilter)

模糊遮罩滤镜(BlurMaskFilter)

BlurMaskFilter.Blur 模式

NORMAL: 内外都模糊绘制
SOLID: 内部正常绘制,外部模糊
OUTER: 内部不绘制,外部模糊
INNER: 内部模糊,外部不绘制

这里写图片描述


    @Override
    protected void onDraw(Canvas canvas) {
        //关闭硬件加速
        setLayerType(View.LAYER_TYPE_SOFTWARE,null);
        //红色的画笔
        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        paint.setColor(Color.RED);
        //NORMAL: 内外都模糊绘制
        paint.setMaskFilter(new BlurMaskFilter(50, BlurMaskFilter.Blur.NORMAL));
        canvas.drawRect(200,100,400,300,paint);
        //SOLID: 内部正常绘制,外部模糊
        paint.setMaskFilter(new BlurMaskFilter(50, BlurMaskFilter.Blur.SOLID));
        canvas.drawRect(600,100,800,300,paint);
        //INNER: 内部模糊,外部不绘制
        paint.setMaskFilter(new BlurMaskFilter(50, BlurMaskFilter.Blur.OUTER));
        canvas.drawRect(200,500,400,700,paint);
        //OUTER: 内部不绘制,外部模糊
        paint.setMaskFilter(new BlurMaskFilter(50, BlurMaskFilter.Blur.INNER));
        canvas.drawRect(600,500,800,700,paint);
    }

浮雕遮罩滤镜(EmbossMaskFilter)

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: Age of Ai 设计师:meimeiellie 返回首页