Android ScriptIntrinsicBlur不会模糊整个图像并生成透明边缘

Rom*_*ski 13 android blur transparent artifact renderscript

我对RenderScript ScriptIntrinsic Blur有一些问题 - 在某些设备上它不会模糊整个图像.我缩小输入图像的尺寸并确保宽度是4的倍数(因为它是由Roman Nurik建议的:https://plus.google.com/+RomanNurik/posts/TLkVQC3M6jW)

@SuppressLint("NewApi")
private Bitmap blurRenderScript(Bitmap smallBitmap) {

    Bitmap output = Bitmap.createBitmap(smallBitmap.getWidth(), smallBitmap.getHeight(), smallBitmap.getConfig());

    RenderScript rs = RenderScript.create(getContext());
    ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
    Allocation inAlloc = Allocation.createFromBitmap(rs, smallBitmap, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_GRAPHICS_TEXTURE);
    Allocation outAlloc = Allocation.createFromBitmap(rs, output);
    script.setRadius(BLUR_RADIUS);
    script.setInput(inAlloc);
    script.forEach(outAlloc);
    outAlloc.copyTo(output);

    rs.destroy();

    MutableBitmap.delete(smallBitmap);

    return output;
}
Run Code Online (Sandbox Code Playgroud)

它正在开发Nexus 4:

Nexus 4模糊之前Nexus 4模糊后

但在Galaxy S4上,右侧有透明边缘:

Galaxy S4在模糊之前模糊后的Galaxy S4

我希望你能看出我的意思 - 如果你用gimp打开图片,或者你可以更好地看到它.它不依赖于图片大小.我也尝试了越来越大的图像,结果总是一样的.例如,它也发生在Nexus 7 2012上.此外,透明工件有时位于bottem或左边缘.在此先感谢您的帮助!

Nexus 4:4.4.2/Build Number KOT49H Galaxy S4:4.2.2/Build Number JDQ39.I9505XXUDMGG

Mat*_*uno 3

我不确定为什么这可能有效,但对我来说它确实有效。

尝试代替

    Bitmap output = Bitmap.createBitmap(smallBitmap.getWidth(), smallBitmap.getHeight(), smallBitmap.getConfig());
Run Code Online (Sandbox Code Playgroud)

像这样传入 Bitmap.Config.ARGB_8888

    Bitmap output = Bitmap.createBitmap(smallBitmap.getWidth(), smallBitmap.getHeight(), Bitmap.Config.ARGB_8888);
Run Code Online (Sandbox Code Playgroud)