整个这个写的mp3中我最喜欢的就是这一点了,背景高斯模糊化。不废话,依旧看代码
package com.verzqli.utils;
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 Klingemann <mario@quasimondo.com>
// 堆栈模糊算法由Mario Klingemann <mario@quasimondo.com>所创作
// 翻译:verzqli,好吧,翻译的就像一坨(ˇˍˇ),英语好的自己理解下
Bitmap bitmap;
if (canReuseInBitmap) {
bitmap = sentBitmap;
} else {
//决定图片像素点的存储,即用图片查看器看图片属性时候的位深参数。
bitmap = sentBitmap.copy(sentBitmap.getConfig(), true);
}
if