Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LOGD("Size of image: %d", data->byteCount);
- jbyteArray imageBuf = p_env->NewByteArray(data->byteCount);
- p_env->SetByteArrayRegion(imageBuf, 0, data->byteCount, (jbyte*)data->buffer); (data->buffer contains byte[])
- jobject imageHashmap = jni_helpers_HashMap_create(p_env); // creates HashMap using NewObject
- jstring key = p_env->NewStringUTF("data");
- jni_helpers_HashMap_put(p_env, imageHashmap, key, imageBuf); // call put method on a HashMap instance
- p_env->DeleteLocalRef(key);
- key = p_env->NewStringUTF("width");
- jobject intVal = jni_helpers_create_Integer(p_env, data->width);
- jni_helpers_HashMap_put(p_env, imageHashmap, key, intVal);
- p_env->DeleteLocalRef(key);
- p_env->DeleteLocalRef(intVal);
- key = p_env->NewStringUTF("height");
- intVal = jni_helpers_create_Integer(p_env, data->height);
- jni_helpers_HashMap_put(p_env, imageHashmap, key, intVal);
- p_env->DeleteLocalRef(intVal);
- p_env->DeleteLocalRef(key);
- p_env->CallVoidMethod(g_callbackTarget, g_callbackMethod, EVENT_ID, (jobject)imageHashmap);
- LOGD("Cleaning up resources...");
- p_env->ReleaseByteArrayElements(imageBuf, (jbyte*)data->buffer, JNI_ABORT); // <!-- this is where I get the message
- p_env->DeleteLocalRef(imageBuf);
- p_env->DeleteLocalRef(imageHashmap);
Advertisement
Add Comment
Please, Sign In to add comment