在Java中,我有用於爲intPointer創建分配的代碼。但是在renderscript計算之後,我無法獲得分配的值。沒有copyTo(int)方法只有byte [],short [],int [],float [],位圖。RenderScript分配。從分配中讀取int
//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[]{0x};
intPointer.copyTo(ints); //does not overwrite the ints the line above
int i = (int)ints[0];
Log.d("ints", String.valueOf(i));
的renderScript:
#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( 「整數」,將String.valueOf(I));給我D/ints﹕ 19088743
和rsDebug(「rs」,* intPointer); 2045 0x7fd
如何從分配中獲取我的int值?
使用此代碼我可以讀取int: int [] ints = new int [] {0x0,0x0}; intPointer = convolution.get_intPointer(); intPointer.copyTo(ints); int []數組需要有兩個元素。 – Penta