Android 用 RenderScript 高斯模糊后,花成一片,到底咋回事儿?有没有大神来解答一下,谢谢!

代码如下:

    private static Bitmap rsBlur(Context context, Bitmap source, int radius){

    //(1)
    RenderScript renderScript =  RenderScript.create(context);

    // Allocate memory for Renderscript to work with
    //(2)
    final Allocation input = Allocation.createFromBitmap(renderScript, source);
    final Allocation output = Allocation.createTyped(renderScript,input.getType());
    //(3)
    // Load up an instance of the specific script that we want to use.
    ScriptIntrinsicBlur scriptIntrinsicBlur = ScriptIntrinsicBlur.create(renderScript, Element.U8_4(renderScript));
    //(4)
    scriptIntrinsicBlur.setInput(input);
    //(5)
    // Set the blur radius
    scriptIntrinsicBlur.setRadius(radius);
    //(6)
    // Start the ScriptIntrinisicBlur
    scriptIntrinsicBlur.forEach(output);
    //(7)
    // Copy the output to the blurred bitmap
    output.copyTo(source);
    //(8)
    renderScript.destroy();

    return source;

}

效果如下
在这里插入图片描述
照片是把drawable转为bitmap,然后再进行模糊化处理,结果就成这样了,有没有大神来看看咋回事啊?

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值