Skip to content Skip to sidebar Skip to footer

Android Getpixels() Possibly A Silly Mistake?

Okay, this is quite simple to understand, but for some bizarre reason I can't get it working.. I've simplified this example from the actual code. InputStream is = context.getResour

Solution 1:

use bitmap width as stride, in ur case 32

 bitmap.getPixels(pixels, 0, 32, 0, 0, 32, 32);

every row gap with 800 causes ur pixelarray to get out of bound

"I'm about to throw the keyboard out of the window " funny lol

Solution 2:

You're overflowing the destination buffer because you're asking for a stride of 800 entries between rows.

http://developer.android.com/reference/android/graphics/Bitmap.html#getPixels%28int[],%20int,%20int,%20int,%20int,%20int,%20int%29

Solution 3:

You getting OutOfBounds exception becacuse stride is applied to pixels array not to the original bitmap,so in your case you're trying to retrieve 32*800 pixels which doesn't fit into your array.

Post a Comment for "Android Getpixels() Possibly A Silly Mistake?"