How to convert C++ Array<float,size> to jfloatArray in JNIWrapper?

234 Views Asked by At

I want to map my C++ array output to jniFloatArray.

Tried to follow this solution:

"Convert float* to jfloatArray using JNI"

but I am unable to point float* to array object.

Let's say my output in C++ array output object is:

output = {1.0f ,2.0f ,3.0f};

What I really want is to convert or map this output (array) to jfloatArray in JniWrapper.

1

There are 1 best solutions below

0
On BEST ANSWER

@Michael solved the problem. So by using output.data() and setting float pointer to it as:

float *ptr = output.data();

solved the issue.