我试图使用FreeImage库文件在我project..causes错误 [英] I am trying to use the freeimage library in my project..causes error
本文介绍了我试图使用FreeImage库文件在我project..causes错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下code片段会导致错误的.... logcat中已经连接...我特林从德的java code传递给NDK code,并从那里图像路径I我试图用FreeImage库文件来打开该位图....
JNIEXPORT无效JNICALL Java_com_example_ImageActivity_brightness(JNIEnv的* ENV,jobject OBJ,的jstring bitmappath,jfloat brightnessValue)
{
AndroidBitmapInfo信息; INT RET;
void *的像素; 如果LString()(bitmappath!); 常量jsize LEN = env-> GetStringUTFLength(bitmappath);
为const char * strChars = env-> GetStringUTFChars(bitmappath,(jboolean *)0); 性病::字符串结果(strChars,LEN); env-> ReleaseStringUTFChars(bitmappath,strChars); FIBITMAP *位= FreeImage_Load(FIF_BMP,Result.c_str(),BMP_DEFAULT);
如果(位图){
//位图加载成功!
FreeImage_Unload(位图);
}
错误日志
羊群@ QS57:〜/桌面/ Android系统的ImageFilter-NDK $ /家庭/羊群/ ANDROID / Android的NDK-R8 / NDK的构建
编译大拇指:图像处理< = imageprocessing.c
JNI / imageprocessing.c:在函数'Java_com_example_ImageActivity_brightness:
JNI / imageprocessing.c:77:错误:没有东西结构或联合请求成员的GetStringUTFLength
JNI / imageprocessing.c:78:错误:请求的东西不是一个结构或联合成员GetStringUTFChars
JNI / imageprocessing.c:80:错误:预期出厂前pression':'令牌
JNI / imageprocessing.c:82:错误:没有东西结构或联合请求成员的ReleaseStringUTFChars
JNI / imageprocessing.c:84:错误:'FIBITMAP'未申报(在一次使用此功能)
JNI / imageprocessing.c:84:错误:(每个未声明的标识符报道只有一次
JNI / imageprocessing.c:84:错误:它出现在每个功能)
JNI / imageprocessing.c:84:错误:未申报的位图(在一次使用此功能)
JNI / imageprocessing.c:84:错误:'FIF_BMP'未申报(在一次使用此功能)
JNI / imageprocessing.c:84:错误:'结果'未声明(第一次使用此功能使用)
JNI / imageprocessing.c:84:错误:'BMP_DEFAULT'未申报(在一次使用此功能)
使:*** [OBJ /本地/ armeabi / OBJ文件/图像处理/ imageprocessing.o]错误1
只有当你编译code
解决方案
您正在调用JNI函数的方法是尽可能C ++ code。
如果您需要或想要编译code为C,那么你必须写在JNI下列方式调用:
常量jsize LEN =(* ENV) - GT; GetStringUTFLength(ENV,bitmappath);
为const char * strChars =(* ENV) - GT; GetStringUTFChars(ENV,bitmappath,(jboolean *)0);
The following code snippet causes error....the logcat has been attached...I am tring to pass the image path from teh java code to the NDK code and from there I am trying to open the bitmap using FreeImage library....
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);
}
Error log
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
解决方案
The way you are calling JNI functions is possible only if you compile code as C++ code.
If you need or want to compile code as C then you must write JNI calls in following way:
const jsize len = (*env)->GetStringUTFLength(env, bitmappath);
const char* strChars = (*env)->GetStringUTFChars(env, bitmappath, (jboolean *)0);
这篇关于我试图使用FreeImage库文件在我project..causes错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文