Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/200.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在Android中使用RenderScript应用模糊会创建奇怪的输出_Java_Android_Renderscript - Fatal编程技术网

Java 在Android中使用RenderScript应用模糊会创建奇怪的输出

Java 在Android中使用RenderScript应用模糊会创建奇怪的输出,java,android,renderscript,Java,Android,Renderscript,我正在尝试使用RenderScript类对图像应用模糊。这是我使用的代码(其中this.image是原始位图) 这是函数的输入和输出 出于某种原因,它似乎将图像加倍,然后只保留绿色通道或其他内容。摆弄模糊半径是不起作用的,我也找不到我的代码有任何错误(它是从一个工作示例中复制的)我也有同样的错误,并找出了原因,我知道这是一个两年前的问题,但仍然适用于那些遇到同样问题的人 问题是我一直使用的图像是RGB_565格式的,因为Renderscript模糊没有从RGB_565图像中获得足够的规格,结果

我正在尝试使用RenderScript类对图像应用模糊。这是我使用的代码(其中this.image是原始位图)

这是函数的输入和输出


出于某种原因,它似乎将图像加倍,然后只保留绿色通道或其他内容。摆弄模糊半径是不起作用的,我也找不到我的代码有任何错误(它是从一个工作示例中复制的)

我也有同样的错误,并找出了原因,我知道这是一个两年前的问题,但仍然适用于那些遇到同样问题的人

问题是我一直使用的图像是RGB_565格式的,因为Renderscript模糊没有从RGB_565图像中获得足够的规格,结果可能是这样的

我使用带有RGB_565配置的UniversalImageLoader来减少内存使用,并在必要时对下载的图像产生模糊效果,当我删除该配置以用作默认的ARGB_8888格式时,一切都很好


总结:使用renderscript blur时不要使用RGB_565,而是使用ARGB_8888。

输入位图的格式是什么?这看起来好像输入是16位的。RS blur仅支持每通道8位位图。有没有发现问题@深覆盖
    Bitmap inputImage = this.image;
    int height = inputImage.getHeight();
    int width = inputImage.getWidth();
    Bitmap blurredImage = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

    RenderScript rs = RenderScript.create(context);
    ScriptIntrinsicBlur theIntrinsic = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
    Allocation tmpIn = Allocation.createFromBitmap(rs, inputImage);
    Allocation tmpOut = Allocation.createFromBitmap(rs, blurredImage);
    theIntrinsic.setRadius(25.f);
    theIntrinsic.setInput(tmpIn);
    theIntrinsic.forEach(tmpOut);
    tmpOut.copyTo(blurredImage);

    this.image = blurredImage;
    return true;