Java RenderScript错误组合用法
我试图创建一个函数,该函数获取renderScript RGBA图像并返回一个带有字节值的矩阵 问题是它返回了以下错误,我搜索了信息,但找不到任何关于它的信息,我找到的唯一替代方法是输出是相同的类型,并且只将结果保存到一个通道中(例如红色) 错误:Java RenderScript错误组合用法,java,android,renderscript,Java,Android,Renderscript,我试图创建一个函数,该函数获取renderScript RGBA图像并返回一个带有字节值的矩阵 问题是它返回了以下错误,我搜索了信息,但找不到任何关于它的信息,我找到的唯一替代方法是输出是相同的类型,并且只将结果保存到一个通道中(例如红色) 错误: 10-15 16: 34: 35.006: E / AndroidRuntime (771): android.support.v8.renderscript.RSIllegalArgumentException: Invalid combinati
10-15 16: 34: 35.006: E / AndroidRuntime (771): android.support.v8.renderscript.RSIllegalArgumentException: Invalid combination usage.
Allocation imageInAlloc = Allocation.createFromBitmap(r, bmp, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
byte[] arrayParams = this.readParamByte(R.raw.params_table);
byte[] arrayColor = new byte[bmp.getWidth()*bmp.getHeight()];
Allocation params_table = Allocation.createSized(r, Element.I8(r), arrayParams.length);
Allocation dataOut = Allocation.createSized(r, Element.U8(r), bmp.getWidth(), bmp.getHeight());
params_table.copyFrom(arrayParams);
script.set_params(params_table);
script.forEach_rootTable(imageInAlloc, dataOut);
dataOut.copyTo(arrayColor);
渲染脚本代码:
void rootTable(const uchar4 *v_in, uchar *v_out){
*v_out = (int)rsGetElementAt_uchar(params, getIndexParams_Table(v_in->r>>3, v_in->g>>3, v_in->b>>3));
}
Java代码:
10-15 16: 34: 35.006: E / AndroidRuntime (771): android.support.v8.renderscript.RSIllegalArgumentException: Invalid combination usage.
Allocation imageInAlloc = Allocation.createFromBitmap(r, bmp, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
byte[] arrayParams = this.readParamByte(R.raw.params_table);
byte[] arrayColor = new byte[bmp.getWidth()*bmp.getHeight()];
Allocation params_table = Allocation.createSized(r, Element.I8(r), arrayParams.length);
Allocation dataOut = Allocation.createSized(r, Element.U8(r), bmp.getWidth(), bmp.getHeight());
params_table.copyFrom(arrayParams);
script.set_params(params_table);
script.forEach_rootTable(imageInAlloc, dataOut);
dataOut.copyTo(arrayColor);
功能是正确的,因此进入和退出的故障率是不同的,但没有办法做到这一点
非常感谢 您上面报告的错误是否有其他堆栈跟踪信息?还有,你改变了单词的顺序了吗?我在代码库的任何地方都找不到“无效组合用法”,但我确实找到了“无效组合用法”(不幸的是,这对于您看到的其他内容仍然没有意义)。至少有一个错误我可以立即发现。您的“params”分配是I8类型的,但随后您将作为uchar从中提取。这是行不通的,因此您需要调用rsGetElementAt_int(),这样您也可以摆脱int强制转换。如果有人有同样的问题,renderScript会检查输入和输出是否是相同的类型,等等。为了避免这种情况,您必须修改ScriptC_uu“filename”.java,并查找forEach_“函数”功能并删除以下内容:
// Verify dimensions
Type tIn = ain.getType();
Type tOut = aout.getType();
if ((tIn.getCount() != tOut.getCount()) ||
(tIn.getX() != tOut.getX()) ||
(tIn.getY() != tOut.getY()) ||
(tIn.getZ() != tOut.getZ()) ||
(tIn.hasFaces() != tOut.hasFaces()) ||
(tIn.hasMipmaps() != tOut.hasMipmaps())) {
throw new RSRuntimeException("Dimension mismatch between input and output parameters!");
}
请不要这样做,因为它保证会破坏您的代码。这里的类型检查是为了确保您的程序能够正确运行。如果您删除这个答案,我将非常感激,因为它对其他开发人员来说是完全误导的。