jni 构建java对象,并设置对象中的值 java对象与C对象对应
jni 构建java对象:Point 对象
java对象与C对象对应
//java
public class Mat
{
public final long nativeObj;//地址 这个地址又可以传到jni中强转过后继续使用
public Mat()
{
nativeObj = m_Mat(rows, cols, type);//c++创建一个对象,返回的是long类型 对象的指针地址
}
public static native long m_Mat(int rows, int cols, int type);
}
//native
JNIEXPORT Jlong *_m_Mat(Jint rows, Jint cols, Jint type)
{
try
{
Size size((int)rows, (int)cols));
return (jlong) new Mat(size, type);
}
catch(...)
{
}
return 0;
}