I am trying to get an android.renderscript.Allocation object to write its results to an int array. The code is short but I'm having a hard time deciphering how to fix it.
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);
The exception I get is:
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
My hunch is that I need to create the int array via Androids built in functions but can't wrap my head around what I should be using. The code is working if I change the return type of the method (and the result object) to a bitmap - but I'd like to return the pixels in the shape of an array.
Thanks
You should be using byte[] for UNSIGNED_8, not int[].