Android Blur效果之FastBlur

               

Blur

自从iOS系统引入了Blur效果,也就是所谓的毛玻璃、模糊化效果,磨砂效果,各大系统就开始竞相模仿,这是一个怎样的效果呢,我们现来看一些图:

iOS / iPhone / iPad 使图片产生模糊化效果。



这些就是典型的Blur效果,在iOS和MIUI中还有很多,这里就不再贴图了。


实现

实现Blur效果主要有两种方式,一个是通过RenderScript来做,另一种是通过直接对像素点来进行算法处理。

RenderScript是API11之后才引入的,所以对版本有限制,而且RenderScript确实挺复杂的,虽然使用他的Blur功能很简单,但是要真正搞懂,不是一天两天的事。

本文主要介绍另一种算法来实现Blur,这个算法是目前市面上对Blur效果处理比较好的一种算法了,研究的前沿网址请戳 我是Blur 。

经典图:


有兴趣的朋友可以去看看。


使用

下面我们来看看如何在Android中来使用Blur,当然,我们需要使用上面提到的FastBlur

package com.xys.blur;import android.graphics.Bitmap;/** * Created by paveld on 3/6/14. */public class FastBlur {    public static Bitmap doBlur(Bitmap sentBitmap, int radius, boolean canReuseInBitmap) {        // Stack Blur v1.0 from        // http://www.quasimondo.com/StackBlurForCanvas/StackBlurDemo.html        //        // Java Author: Mario Klingemann <mario at quasimondo.com>        // http://incubator.quasimondo.com        // created Feburary 29, 2004        // Android port : Yahel Bouaziz <yahel at kayenko.com>        // http://www.kayenko.com        // ported april 5th, 2012        // This is a compromise between Gaussian Blur and Box blur        // It creates much better looking blurs than Box Blur, but is        // 7x faster than my Gaussian Blur implementation.        //        // I called it Stack Blur because this describes best how this        // filter works internally: it creates a kind of moving stack        // of colors whilst scanning through the image. Thereby it        // just has to add one new block of color to the right side        // of the stack and remove the leftmost color. The remaining        // colors on the topmost layer of the stack are either added on        // or reduced by one, depending on if they are on the right or        // on the left side of the stack.        //        // If you are using this algorithm in your code please add        // the following line:        //        // Stack Blur Algorithm by Mario 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值