Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.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
Android:从renderscript的像素数组创建分配_Android_Allocation_Renderscript - Fatal编程技术网

Android:从renderscript的像素数组创建分配

Android:从renderscript的像素数组创建分配,android,allocation,renderscript,Android,Allocation,Renderscript,我正在尝试使用Android Renderscript模糊图像。我的输入是一个包含像素颜色的整数数组。以下是我做过的和没有做过的。Galaxy S设备上的应用程序已关闭,但未显示任何错误消息 bmp.getPixels(pixels, 0, bmp.getWidth(), 0, 0, bmp.getWidth(), bmp.getHeight()); Allocation input = Allocation.createSized(rs, Element.I32(rs), p

我正在尝试使用Android Renderscript模糊图像。我的输入是一个包含像素颜色的整数数组。以下是我做过的和没有做过的。Galaxy S设备上的应用程序已关闭,但未显示任何错误消息

    bmp.getPixels(pixels, 0, bmp.getWidth(), 0, 0, bmp.getWidth(), bmp.getHeight());

    Allocation input = Allocation.createSized(rs, Element.I32(rs), pixels.length);
    input.copy1DRangeFrom(0, pixels.length, pixels);

    Allocation output = Allocation.createTyped(rs, input.getType());
    ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
    script.setRadius(6f);
    script.setInput(input);
    script.forEach(output);

    output.copyTo(pixels);

您需要查看logcat输出(确保androidstudio/Eclipse中没有打开任何过滤器),它将显示崩溃


您看到的问题很可能是因为您的输入
分配
元素类型与输出不匹配。它们必须是一样的。与其调用
Allocation.createSize()
并指定一个元素,只需调用并为其提供输入
Bitmap
对象即可。然后将输入的
位图
复制到
分配

如果日志中没有错误,应用程序将停止在“output.copyTo”行。在我的例子中,我没有位图,输入是一个包含像素的数组。从该数组创建位图以用于分配不是一个解决方案,因为它会减慢进程,我需要速度,这是一个实时进程。logcat中必须有一些内容,所有崩溃都会被记录,即使是在本机代码或RS中,也必须创建位图或将其放入字节数组中,这样分配才能与U8_4兼容。