Android开发之毛玻璃效果实例代码开发之毛玻璃效果实例代码
这是在网上找的,不过忘了在哪里找的,经过很多比较测试,发现这个方法不会 oom,目前来看 我一直没有遇过,今天才找
到这个以前建立的工程,记录下来:
先给大家展示下效果图:先给大家展示下效果图:
public class FastBlur
{
public static Bitmap doBlur(Bitmap sentBitmap, int radius, boolean canReuseInBitmap) {
// 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:
// 如果你在你的代码中使用这个算法,请添加下面这行