相关疑难解决方法(0)

从JNI/NDK返回从C到Java的2D原始数组

我已经找到了大量关于如何在JNI中生成2D原始数组并将其返回给Java的文档.但是这些信息无法描述如何在C中给出上下文传递已经存在的 2D浮点数组(float**).

为了明确地描述我的问题,我将添加一些我想要实现的C伪代码:

// Returns a 2D float array from C to Java
jfloatArray ndk_test_getMy2DArray(JNIEnv* env, jobject thiz, jlong context)
{
    // Cast my context reference
    MyContextRef contextRef = (MyContextRef) context;

    // In case we need it below
    unsigned int length = MyContextGet1DLength(contextRef);

    // Get the 2D Array we want to "Cast"
    float** primitive2DArray = MyContextGet2DArray(contextRef);

    // Hokus pokus...
    // We do something to create the returnable data to Java
    //
    // Below is the …
Run Code Online (Sandbox Code Playgroud)

c java java-native-interface multidimensional-array android-ndk

9
推荐指数
1
解决办法
7552
查看次数