如何从Renderscript分配中访问键入的数据?

时间:2013-03-05 16:38:35

标签: android renderscript

我用这种方式创建了类型化的RS分配:

mRS = RenderScript.create(mContext);
Element.Builder eb = new Element.Builder(mRS);
eb.add(Element.F32_3(mRS), "xyz");
eb.add(Element.F32_2(mRS), "uv");
Element eStride_XYZUV = eb.create();

mInAllocation = Allocation.createSized(mRS, eStride_XYZUV, animLand.getArray().length / 5);
mOutAllocation = Allocation.createSized(mRS, eStride_XYZUV, animLand.getArray().length / 5);

animLand.getArray()float的数组。我可以将数据复制到输入分配:

mInAllocation.copyFromUnchecked(animLand.getArray());

但是,当我尝试以这种方式从分配中检索数据时:

mOutAllocation.copyTo(animLand.getArray());

我得到例外:

android.renderscript.RSIllegalArgumentException: 32 bit float source does not match allocation type null

如何使用自定义Allocation数组从输出Element访问数据?有方法可以复制到数组/位图,但只能用于原始Element类型。

如果我使用原始F32类型但我想使用类型数据

,它会起作用
mInAllocation = Allocation.createSized(mRS, Element.F32(mRS), animLand.getArray().length);
mOutAllocation = Allocation.createSized(mRS, Element.F32(mRS), animLand.getArray().length);
...
mInAllocation.copyFromUnchecked(animLand.getArray());
...
mOutAllocation.copyTo(animLand.getArray());

0 个答案:

没有答案