Return a 2D primitive array from C to Java from JNI/NDK

后端 未结 3 1985
暖寄归人
暖寄归人 2020-12-16 03:21

I have found large amounts of documentation on how to generate a 2D primitive array in JNI and returning it to Java. But these pieces of information fail to describe how to

3条回答
  •  独厮守ぢ
    2020-12-16 03:43

    Unfortunately I don't think you can pass C floats up to Java, you'll have to turn the array into a 2D array of jfloats by converting every member into a jFloat.

    Essentially, you'll have to create the multidimensional jFloatArray, then iterate through the native C array, convert every element into its jFloat representation and store it into the same position in the jFloatArray you just created.

    This part of the documentation should explain it in a bit more depth.

提交回复
热议问题