I wrote some JNI to run on Android, it works great except its crashing on the last line. So I was wondering if you can please see if I am using getPixels correct. Documentation for getPixels
: http://developer.android.com/reference/android/graphics/Bitmap.html#getPixels%28int%5B%5D,%20int,%20int,%20int,%20int,%20int,%20int%29
This is my full code: https://gist.github.com/Noitidart/cb6e7c3a102784d04262
This is the relavent parts:
var bmp = Bitmap.createBitmap(width, height, Bitmap_Config.ARGB_8888);
var rgba = JNI.jint.array(4 * width * height)();
bmp.getPixels(
rgba,
0,
width * 4, // stride
0,
0,
width,
height
);
I'm unsure if I am setting right size to my rgba array, and if I set the stride right. I did width * 4
for stride because rgba is 4 numbers per pixel. And thats also why I did width * 4 * height
for the size of the rgba
array.
Please advise