【发布时间】:2014-03-01 16:28:16
【问题描述】:
在 Java 中,我有这段代码用于为 intPointer 创建分配。但是在渲染脚本计算之后,我无法取回分配的值。没有copyTo(int)方法只有byte[], short[], int[], float[], bitmap。
//Create Allocation
Allocation intPointer = Allocation.createSized(renderScript, Element.I32(renderScript), 2);
convolution.bind_intPointer(intPointer);
convolution.forEach_root(allocationOut);
[...]
//read Allocation, not working
int[] ints = new int[]{0x01234567};
intPointer.copyTo(ints); //does not overwrite the ints the line above
int i = (int)ints[0];
Log.d("ints", String.valueOf(i));
渲染脚本:
#pragma version(1)
#pragma rs java_package_name(package com.ap.wificam)
#pragma rs_fp_imprecise
rs_allocation input;
rs_allocation mask;
int32_t *intPointer = 0;
void root(uchar4* out, uint32_t x, uint32_t y) {
//do some stuff
if((sum.x + sum.y + sum.z)/3 > *intPointer)
*intPointer = (sum.x + sum.y + sum.z)/3; //wirte data to intPointer
*out = convert_uchar4(sum);
}
Log.d("ints", String.valueOf(i));给我D/ints﹕ 19088743
和 rsDebug("rs", *intPointer); 2045 0x7fd
如何从分配中获取我的 int 值?
【问题讨论】:
-
使用这段代码我可以读取 int: int[] ints = new int[]{0x0,0x0}; intPointer = 卷积.get_intPointer(); intPointer.copyTo(ints); int[] 数组需要有两个元素。
标签: android renderscript