我正在处理一个C++库,它将图像字节数据存储在一个无符号字符数组中。我的jni函数返回一个jByteArray(然后转换为Java端的BufferedImage),但我不知道如何从无符号字符数组中填充jByteArray(如果可能的话)。任何人都可以进行这最后一部分,基本上做到这一点提供了一个片段:JNI无符号字符到字节数组
// 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?
感谢, 杰夫
我在这里有点困惑。复制原始的unsigned char数组(不是jarray)在哪里发生? – 2011-01-06 01:57:07
请参阅编辑后的版本。 – bmargulies 2011-01-06 01:58:51
谢谢。感谢帮助。 – 2011-01-06 02:49:28