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

Khubaib Ahmad :

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.

Khubaib Ahmad :

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

float *ptr = output.data();

solved the issue.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=305314&siteId=1