gpt4 book ai didi

android - 我正在尝试在我的项目中使用 freeimage 库..导致错误

转载 作者:行者123 更新时间:2023-11-29 22:02:27 24 4
gpt4 key购买 nike

以下代码 fragment 导致错误....已附加 logcat...我试图将图像路径从 java 代码传递到 NDK 代码,然后我尝试使用 FreeImage 库打开位图....

JNIEXPORT void JNICALL Java_com_example_ImageActivity_brightness(JNIEnv* env, jobject  obj, jstring bitmappath, jfloat brightnessValue)
{
AndroidBitmapInfo info;

int ret;
void* pixels;

if ( !bitmappath ) LString();

const jsize len = env->GetStringUTFLength(bitmappath);
const char* strChars = env->GetStringUTFChars(bitmappath, (jboolean *)0);

std::string Result(strChars, len);

env->ReleaseStringUTFChars(bitmappath, strChars);

FIBITMAP *bitmap = FreeImage_Load(FIF_BMP,Result.c_str(), BMP_DEFAULT);
if (bitmap) {
// bitmap successfully loaded!
FreeImage_Unload(bitmap);
}

错误日志

flock@QS57:~/Desktop/android-imagefilter-ndk$ /home/flock/ANDROID/android-ndk-r8/ndk-build
Compile thumb : imageprocessing <= imageprocessing.c
jni/imageprocessing.c: In function 'Java_com_example_ImageActivity_brightness':
jni/imageprocessing.c:77: error: request for member 'GetStringUTFLength' in something not a structure or union
jni/imageprocessing.c:78: error: request for member 'GetStringUTFChars' in something not a structure or union
jni/imageprocessing.c:80: error: expected expression before ':' token
jni/imageprocessing.c:82: error: request for member 'ReleaseStringUTFChars' in something not a structure or union
jni/imageprocessing.c:84: error: 'FIBITMAP' undeclared (first use in this function)
jni/imageprocessing.c:84: error: (Each undeclared identifier is reported only once
jni/imageprocessing.c:84: error: for each function it appears in.)
jni/imageprocessing.c:84: error: 'bitmap' undeclared (first use in this function)
jni/imageprocessing.c:84: error: 'FIF_BMP' undeclared (first use in this function)
jni/imageprocessing.c:84: error: 'Result' undeclared (first use in this function)
jni/imageprocessing.c:84: error: 'BMP_DEFAULT' undeclared (first use in this function)
make: *** [obj/local/armeabi/objs/imageprocessing/imageprocessing.o] Error 1

最佳答案

只有将代码编译为 C++ 代码时,调用 JNI 函数的方式才有可能。

如果您需要或想要将代码编译为 C,那么您必须按以下方式编写 JNI 调用:

const jsize len      = (*env)->GetStringUTFLength(env, bitmappath);
const char* strChars = (*env)->GetStringUTFChars(env, bitmappath, (jboolean *)0);

关于android - 我正在尝试在我的项目中使用 freeimage 库..导致错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11624503/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com