下面的代码片段导致错误...... 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