Generic Java - cast int[] to byte[]
Please Login to Remove!
Dealing with an 8 bit byte array is much slower than a 32 bit int array, so I want to use the same technique I use in C, which is to perform binary arithmetic in 32 bit, then cast the int array to a byte array. An actual conversion is out of the question, and would defeat the whole purpose.
The specific reason is the Bitmap constructor takes a byte[] for raw data, but manipulating bytes is too slow, so I need to access the array as int[] (each element being a pair of pixels), then pass it to the Bitmap constructor as byte[].
A simple cast to (byte[]) results in an "inconvertible types" compiler error. Any way to do this?
Last edited by Dan East; 10-11-2008 at 09:46 PM..
|