Android 毛玻璃 毛不毛不知道 但是真皮

1.关于 CV这种事,强调了很多遍,关键字,现在一步一步捋下过程,

一.拿到需求  毛玻璃效果

神马 都不要看,直接去github 官网,看看代码冗余么,好接入么,多的话直接pass,看关键字blur

二.github

 

开始核对需求效果,然后再看能不能接入,同样看冗余,

3.github依赖炸了

然而他的star很多,依赖不能用,那是不可能的,有很大的几率是最新版本有问题不兼容,可以找历史版本或者直接项目名百度,看看有木有人使用过这个库,看看别人走过 的 坑!

最后

https://github.com/mmin18/RealtimeBlurView  这个性能高 星多

https://github.com/nbwzlyd/realTimeBlurView2  星少 可能兼容性更高  效果差不多 

第一个版本不行

compile 'com.github.mmin18:realtimeblurview:1.0.3'
public class CustomShapeBlurView extends RealtimeBlurView {
    Paint mPaint;
    RectF mRectF;

    public CustomShapeBlurView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mPaint = new Paint();
        mRectF = new RectF();
    }

    /**
     * Custom oval shape
     */
    @Override
    protected void drawBlurredBitmap(Canvas canvas, Bitmap blurredBitmap, int overlayColor) {
        if (blurredBitmap != null) {
            int width = getWidth();
            int height = getHeight();

            mRectF.right = width;
            mRectF.bottom = height;

            mPaint.reset();
            mPaint.setAntiAlias(true);
            BitmapShader shader = new BitmapShader(blurredBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
            Matrix matrix = new Matrix();
            matrix.postScale(mRectF.width() / blurredBitmap.getWidth(), mRectF.height() / blurredBitmap.getHeight());
            shader.setLocalMatrix(matrix);
            mPaint.setShader(shader);
            canvas.drawOval(mRectF, mPaint);

            mPaint.reset();

            mPaint.setAntiAlias(true);
            mPaint.setColor(overlayColor);

            RectF rectF = new RectF(0, 0, width, height);
            canvas.drawRoundRect(rectF, 30, 30, mPaint);

        }
    }
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值