Open Noitidart opened 9 years ago
I got it to make an array I think:
var rgba = JNI.jint.array(4 * width * height)();
console.info('rgba:', rgba.toString());
However this is where it crashes:
bmp.getPixels(rgba, 0, width * 4, 0, 0, width, height);
console.info('rgba:', rgba.toString());
My full code is here: https://gist.github.com/Noitidart/e988e060e1e4942e38ce
Final step baby!
I'm thinking maybe the getPixels
function is throwing one of the errors from the documentation: http://developer.android.com/reference/android/graphics/Bitmap.html#getPixels%28int[],%20int,%20int,%20int,%20int,%20int,%20int%29
Either IllegalArgumentException
or ArrayIndexOutOfBoundsException
does JNI.jsm
crash on exception thrown? Or does it log it to console?
I might be creating the array wrong, as when you do hte var sa = StringArray.new
it returns:
http://mxr.mozilla.org/mozilla-central/source/mobile/android/modules/JNI.jsm#1047 which is return wrap(j[constructor].call(j, jenv, length), classSig);
im not sure if var rgba = JNI.jint.array(#)
is same as that. May you please review my array creation and feed to getPixels
I started the JNI documention, im still crashing on this getPixels code if you could please help me with that, that would be awesome.
JNI documentation: https://developer.mozilla.org/en-US/docs/Mozilla/js-ctypes/Examples/Using_JNI_from_js-ctypes
Copy paste code where getPixel is problem: https://gist.github.com/Noitidart/cb6e7c3a102784d04262/276832e9707470ce7a30b7239d06a2928422e9c4#file-_ff-addon-snippet-jniscreenshot-js-L144
I tried this code with the *4
too but still crashing :(
Hi there Dr I know you are probably busy but I am really stuck on the getPixels
line of this code, I was wondering if you could please help me out.
I released version 1 of my addon without Android support, it works on desktop Linux, Mac, and Windows check it out please I think you'll like it and maybe be more into helping me bring it to Android :) https://addons.mozilla.org/en-US/firefox/addon/nativeshot/
Will just need few minutes of your time please, nothing too much.
Hi there @cscott is this correct way to make an array of int? Its not causing crash anymore:
JNI.LoadClass(my_jenv, '[' + SIG.int);
var IntArray = JNI.classes.int.array;
var rgba = IntArray.new(width * height);
// var rgba = JNI.jint.array(width * height)(); // bad way, which was causing crash
console.info('rgba:', rgba['js#obj'].toString());
bmp.getPixels(rgba, 0, width, 0, 0, width, height);
console.info('rgba:', rgba['js#obj'].toString());
I am not able to figure out how to make an array?
I keep getting a bunch of errors, like
new
is not a function of intArray. I also triedintArray(4*width*height)
and alsointArray(4*width*height)
but cant get it to work :(I was trying to follow your example here: https://github.com/cscott/intent-addon/blob/338deef9fb5dbca9bdb62d85ad8020c49cf6bb97/lib/main.js#L96-L120