2
我想獲得一個android.renderscript.Allocation對象將其結果寫入一個int數組。代碼很短,但我很難解釋如何解決它。如何爲Android的renderscript創建一個unsigned 8 int數組?
int[] result = new int[bitmap.getWidth() * bitmap.getHeight()];
inAllocation = Allocation.createFromBitmap(mRS, src,Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
outAllocation = Allocation.createTyped(mRS, inAllocation.getType());
outAllocation.copyTo(result);
我得到的例外是:
10-15 19:21:07.084: E/AndroidRuntime(9021): Caused by: android.renderscript.RSIllegalArgumentException: 32 bit integer source does not match allocation type UNSIGNED_8
我的直覺是,我需要建立通過內置函數機器人會的int數組,但不能換我的頭周圍有什麼,我應該使用。如果我將方法(和結果對象)的返回類型更改爲位圖,代碼正在工作 - 但我想要返回數組形狀的像素。
感謝