Hi my task is to display a set of decoded frames in android. In my native code i have a character(char ) pointer which holds the address of the decoded frame. I want to display this frame on my device so i got a hint from: Displaying YUV Image in Android hence in my activity class i wrote the following function:
public void displayFrame(byte[] data, int fwidth,int fheight){
ImageView frameImgView=(ImageView) findViewById(R.id.imageView2);
ByteArrayOutputStream out=new ByteArrayOutputStream();
YuvImage yuvimg=new YuvImage(data, ImageFormat.NV21, fwidth, fheight, null);
yuvimg.compressToJpeg(new Rect(0, 0, fwidth, fheight), 100, out);
byte[] imageBytes = out.toByteArray();
Bitmap image = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length);
frameImgView.setImageBitmap(image);
return;
}
Hence from my native code i need to call this function in java. From the link: http://www.altdevblogaday.com/2011/12/09/running-native-code-on-android-part-1/ i got to know how to call a java function from native c. However to call a java function we need an environment variable to do that. Im my java class i hav declared the main function as native and generated a header for that main function:
JNIEXPORT jint JNICALL Java_com_example_decoder_Decoder_mainFunction(JNIEnv *env, jclass jobj, jint argc, jstring argv1, jstring argv2);
however my mainFunction calls a function "fwriter(some pointer, some pointer)" which has a pointers as parameters. How do i get environment variable for the same. I know that in java class i need to declare "fwriter" function as native but what do i represent pointers as??
eg: my c function is:
void fwriter(int *ptr, char *ptr)
{
....
}
In my java class how do i declare this function as native?? Please help. Any other methods to diaplay YUV in java/Android will also be appreciated. Thank you.