package com.pingan.carowner.servicewindow.utils;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
import android.renderscript.ScriptIntrinsicBlur;
/**
* @author zhangshuzhi
* @time 2016/5/24 10:27
* @des 图片高斯模糊处理
*/
public class ImgGaussianBlur {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static Bitmap blurBitmap(Bitmap bitmap, Context context){
if(null == bitmap){
bitmap = BitmapFactory.decodeResource(context.getResources(),
R.drawable.personnal_information_default);
}
//Let's create an empty bitmap with the same size of the bitmap we want
to blur
Bitmap outBitmap = Bitmap.createBitmap(bitmap.getWidth(),
bitmap.getHeight(), Bitmap.Config.ARGB_8888);
//Instantiate a new Renderscript
RenderScript rs = RenderScript.create(context);
//Create an Intrinsic Blur Script using the Renderscript
ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs,
Element.U8_4(rs));
//Create the Allocations (in/out) with the Renderscript and the in/out
bitmaps
Allocation allIn = Allocation.createFromBitmap(rs, bitmap);
Android 高斯模糊
最新推荐文章于 2024-05-15 19:44:03 发布