Browse Source

android: fix issue loading some image files

rdb 7 years ago
parent
commit
10789f6936

+ 4 - 1
panda/src/android/pnmFileTypeAndroid.cxx

@@ -21,7 +21,10 @@
 #include "bamReader.h"
 #include "bamReader.h"
 
 
 static const char * const extensions_android[] = {
 static const char * const extensions_android[] = {
-  "jpg", "jpeg", "gif", "png",//"webp" (android 4.0+)
+  "jpg", "jpeg", "gif", "png",
+#if __ANDROID_API__ >= 14
+  "webp"
+#endif
 };
 };
 static const int num_extensions_android = sizeof(extensions_android) / sizeof(const char *);
 static const int num_extensions_android = sizeof(extensions_android) / sizeof(const char *);
 
 

+ 1 - 0
panda/src/android/pnmFileTypeAndroidReader.cxx

@@ -87,6 +87,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) :
   jobject opts = _env->CallStaticObjectMethod(jni_PandaActivity,
   jobject opts = _env->CallStaticObjectMethod(jni_PandaActivity,
                                               jni_PandaActivity_readBitmapSize,
                                               jni_PandaActivity_readBitmapSize,
                                               (jlong) _file);
                                               (jlong) _file);
+  _file->clear();
   _file->seekg(pos);
   _file->seekg(pos);
   if (_file->tellg() != pos) {
   if (_file->tellg() != pos) {
     android_cat.error()
     android_cat.error()

+ 1 - 1
panda/src/pnmimagetypes/pnmFileTypeStbImage.cxx

@@ -62,7 +62,7 @@
 
 
 static const char *const stb_extensions[] = {
 static const char *const stb_extensions[] = {
   // Expose the extensions that we don't already expose through other loaders.
   // Expose the extensions that we don't already expose through other loaders.
-#ifndef HAVE_JPEG
+#if !defined(HAVE_JPEG) && !defined(ANDROID)
   "jpg", "jpeg",
   "jpg", "jpeg",
 #endif
 #endif
 #ifndef HAVE_PNG
 #ifndef HAVE_PNG