JNI unsigned char to byte array
Posted
by
Jeff Storey
on Stack Overflow
See other posts from Stack Overflow
or by Jeff Storey
Published on 2011-01-06T00:45:29Z
Indexed on
2011/01/06
4:53 UTC
Read the original article
Hit count: 353
I'm working with a C++ library that stores image byte data in an array of unsigned characters. My jni function returns a jByteArray (which then gets converted to a BufferedImage on the java side), but I'm not sure how to fill the jByteArray from the unsigned character array (if it is possible). Can anyone provide a snippet for this last part to basically do this:
// size is the size of the unsigned char array
const int size = 100;
unsigned char* buf = new unsigned char[size];
// buf gets passed to another library here to be populated
jbyteArray bArray = env->NewByteArray(size);
// now how do I get the data from buf to bArray?
Thanks, Jeff
© Stack Overflow or respective owner