RenderScript:非致命 RS 错误,forEach 内核索引超出范围
RenderScript: non fatal RS error, The forEach kernel index is out of bounds
我正在尝试 运行 一个简单的 RenderScript 示例,但出现以下错误:
01-03 16:10:04.723 25608-28248/com.testing.android E/RenderScript_jni: non fatal RS error, The forEach kernel index is out of bounds
导致此问题的代码是:
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_img_name);
ScriptC_test test = new ScriptC_test(mRS);
Allocation in = Allocation.createFromBitmap(mRS, bitmap);
Allocation out = Allocation.createTyped(mRS, in.getType());
test.forEach_grayscale(in, out);
out.copyTo(bitmap);
我的 RS 文件如下所示:
#pragma version(1)
#pragma rs java_package_name(com.testing.android)
uchar4 RS_KERNEL grayscale(uchar4 pixelIn, uint32_t x, uint32_t y) {
uchar grayscale = (pixelIn.r + pixelIn.g + pixelIn.b) / 3; // simple average
uchar4 pixelOut;
pixelOut.a = pixelIn.a;
pixelOut.r = grayscale;
pixelOut.g = grayscale;
pixelOut.b = grayscale;
return pixelOut;
}
有人知道上面的代码可能有什么问题吗?
谢谢!
我通过从支持库 (android.support.v8.renderscript) 切换到本机库 (android.renderscript) 解决了这个问题。
如果有人知道为什么这会有所不同,请告诉我!
我正在尝试 运行 一个简单的 RenderScript 示例,但出现以下错误:
01-03 16:10:04.723 25608-28248/com.testing.android E/RenderScript_jni: non fatal RS error, The forEach kernel index is out of bounds
导致此问题的代码是:
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_img_name);
ScriptC_test test = new ScriptC_test(mRS);
Allocation in = Allocation.createFromBitmap(mRS, bitmap);
Allocation out = Allocation.createTyped(mRS, in.getType());
test.forEach_grayscale(in, out);
out.copyTo(bitmap);
我的 RS 文件如下所示:
#pragma version(1)
#pragma rs java_package_name(com.testing.android)
uchar4 RS_KERNEL grayscale(uchar4 pixelIn, uint32_t x, uint32_t y) {
uchar grayscale = (pixelIn.r + pixelIn.g + pixelIn.b) / 3; // simple average
uchar4 pixelOut;
pixelOut.a = pixelIn.a;
pixelOut.r = grayscale;
pixelOut.g = grayscale;
pixelOut.b = grayscale;
return pixelOut;
}
有人知道上面的代码可能有什么问题吗?
谢谢!
我通过从支持库 (android.support.v8.renderscript) 切换到本机库 (android.renderscript) 解决了这个问题。
如果有人知道为什么这会有所不同,请告诉我!