Well, this is pretty easy to understand, but for some bizarre reason, I can't get it to work. I simplified this example from the actual code.
InputStream is = context.getResources().openRawResource(R.raw.someimage); Bitmap bitmap = BitmapFactory.decodeStream(is); try { int[] pixels = new int[32*32]; bitmap.getPixels(pixels, 0, 800, 0, 0, 32, 32); } catch(ArrayIndexOutOfBoundsException ex) { Log.e("testing", "ArrayIndexOutOfBoundsException", ex); }
Why do I keep getting an ArrayIndexOutOfBoundsException? an array of 32x32 pixels, and as far as I know, I use getPixels correctly. Image sizes are 800x800, and I'm trying to get a 32x32 partition. The image is a 32-bit PNG that is reported as ARGB-8888.
Any ideas? even if I'm an idiot! I'm going to throw the keyboard out of the window: D
source share