0

I have a native C++ module that loads image files using libjpeg and lodepng. In iOS everything works fine, i can refer to an image like that : ...myAppBundleSrc/myImages/myImage.png

I am porting my code to android. I successfully built my module with ndk. The problem is that i don't know what file path i should pass to my image loading library in C++. I tried "file:///android_asset/myImages/myImage.png" without success.

My import code in c++

#ifdef _ANDROID
#include <sys/types.h>
#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>
#endif

My android.mk

LOCAL_LDLIBS := -llog -landroid -lGLESv2 -L$(LOCAL_PATH)/libraries
AkademiksQc
  • 677
  • 1
  • 6
  • 20
  • indeed thx for the quick reply...so it seems i need to extract & copy the assets to the sdcard first and then i can read them – AkademiksQc Feb 22 '13 at 19:27
  • You don't necessarily need to extract and copy the assets... you can ask the asset manager to either get you an in-memory copy (via `AAsset_read`) or a pointer to the memory mapped file (via `AAsset_getBuffer`, which will only work if the file is uncompressed in the APK). Both LodePNG and libpng can then work with this in-memory representation. – addaon Feb 23 '13 at 04:30
  • Yes you are right, it does not make much sense to duplicate the ressources to the SD card...better read them directly with the asset manager. That is what i am trying to do now but when i ndk-build i always get the following error : error: undefined reference to 'AAssetManager_fromJava' even if i the includes the correct headers in my cpp file and i link with -landroid in the android.mk. Check the update post above to see my code – AkademiksQc Feb 24 '13 at 14:35
  • Just found out why i was getting the not found error...so stupid. I was editing an older version of my android.mk ! doh! The so file gets properly generated now. – AkademiksQc Feb 24 '13 at 15:04

0 Answers0