Not very sure, the code of the previous period did not have problems, but today debugging for half a day, has been crashing: VM aborting.
Previous part of the code:
1JniexportvoidJnicall XXX2(jnienv*env,jobject Thiz, Jobject bitmap, Jbytearray databuf, jint width, jint height)3 {4jboolean* Parraydata = (jboolean*) env->getprimitivearraycritical (Databuf,0);5 androidbitmapinfo info;6 intret;7 if(ret = Androidbitmap_getinfo (env, Bitmap, &info)) <0)8 {9 XXX;Ten } One if(Info.format! =android_bitmap_format_rgba_8888) A { - XXX; - } the if(ret = androidbitmap_lockpixels (env, Bitmap, &pixels)) <0) - { - XXX; - } + androidbitmap_unlockpixels (env, bitmap); -Env->releaseprimitivearraycritical (Databuf, Parraydata,0); +}
Later found that do not bitmap the code program is correct, or comment out the getprimitivearraycritical of the relevant code program is correct. But when both come together, the program crashes.
Then think about not using getprimitivearraycritical, and try it with another code.
1UnsignedChariscopy;2jbyte* parrayimgdata = env->getbytearrayelements (databuf,&iscopy); % It doesn't matter if you use iscopy here, as long as the last release corresponds to the line.
3 if(ret = Androidbitmap_getinfo (env, bitmaps, &info)) <0)
4 {5 XXX;6 } 7 XXX;8Env->releasebytearrayelements (databuf,parrayimgdata,iscopy);
The program will not crash.
PS: Still do not understand why the previous code can be used, today is not available (of course, there are other code in the previous code, today only use the part of the code).
Conflicts between Env->getbytearrayelements and Androidbitmap_getinfo in JNI (formerly)