Need help with Blur?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

robinxdroid
130 Stars 34 Forks Apache License 2.0 15 Commits 5 Opened issues

Description

[DEPRECATED]请移步https://github.com/robinxdroid/BlurView

Services available

!
?

Need anything else?

Contributors list

Blur

[DEPRECATED]此库不再更新,新库地址:https://github.com/robinxdroid/BlurView

高斯模糊库,四种模糊方式

Support

1 Blur 四种模糊方式:RenderScript; Native Pixels; Native Bitmap; Java
2 BlurDrawable 实时模糊Drawable
3 BlurMaskRelativeLayout 模糊底层背景Layout
4.BlurRelativeLayout  模糊当前控件Background

Example

Download demo.apk

Screenshot

Usage

Gradle:

java
    compile 'net.robinx:lib.blur:1.0.1'

Blur:

blurBitmap = StackBlur.blurJava(willBlurBitmap, blurRadius, false);  //Java方式,缺点:相对于下面三种,速度慢,模糊大图时容易OOM

blurBitmap = StackBlur.blurNatively(willBlurBitmap, blurRadius, false); //Native Bitmap 方式,NDK实现,与Native Pixels方式差距不大

blurBitmap = StackBlur.blurNativelyPixels(willBlurBitmap, blurRadius, false); //Native Pixels方式 ,NDK实现,推荐使用

blurBitmap = StackBlur.blurRenderScript(context,willBlurBitmap, blurRadius, false); //RenderScript方式,速度极快,约为java方式100倍的速度,NDK方式20倍速度(不同图片质量测试所得结果不同,仅供参考),缺点:API17以上有效, // radius最大只能设置25,导致模糊的深度不够,不过可以先压缩图片,此问题不是太严重,如果可以忽略API 17的问题,此方式首选

BlurDrawable

扩展Drawable可设置为任何View背景,缺点:实时Blur为了保证FPS使用了RenderScript模糊方式,API 17以上有效

 BlurDrawable blurDrawable = new BlurDrawable(BlurDrawableActivity.this);
                blurDrawable.setDrawOffset(mBlurDrawableRelativeLayout.getLeft(), mBlurDrawableRelativeLayout.getTop() + BlurUtils.getStatusBarHeight(BlurDrawableActivity.this));
                blurDrawable.setCornerRadius(10);
                blurDrawable.setBlurRadius(10);
                blurDrawable.setOverlayColor(Color.parseColor("#64ffffff"));
                mBlurDrawableRelativeLayout.setBackgroundDrawable(blurDrawable);

BlurMaskRelativeLayout

模糊遮罩Layout,可对底层背景进行模糊,此View设置Background无效

1.XML:

 
        
    

2.代码中使用:

java
mBlurMaskRelativeLayout = (BlurMaskRelativeLayout) this.findViewById(R.id.blur_mask_container);
mBlurMaskRelativeLayout.blurMode(BlurMode.RENDER_SCRIPT)
                 .blurRadius(4);

BlurRelativeLayout

对Background进行模糊

    
        
    

About me

Email:[email protected]
Blog:www.robinx.net

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.