Loading core/jni/android/graphics/BitmapFactory.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -517,6 +517,11 @@ static void nativeSetDefaultConfig(JNIEnv* env, jobject, int nativeConfig) { } } static jboolean nativeIsSeekable(JNIEnv* env, jobject, jobject fileDescriptor) { jint descriptor = env->GetIntField(fileDescriptor, gFileDescriptor_descriptor); return ::lseek64(descriptor, 0, SEEK_CUR) != -1 ? JNI_TRUE : JNI_FALSE; } /////////////////////////////////////////////////////////////////////////////// static JNINativeMethod gMethods[] = { Loading Loading @@ -546,6 +551,11 @@ static JNINativeMethod gMethods[] = { }, { "nativeSetDefaultConfig", "(I)V", (void*)nativeSetDefaultConfig }, { "nativeIsSeekable", "(Ljava/io/FileDescriptor;)Z", (void*)nativeIsSeekable }, }; static JNINativeMethod gOptionsMethods[] = { Loading graphics/java/android/graphics/BitmapFactory.java +16 −4 Original line number Diff line number Diff line Loading @@ -564,11 +564,22 @@ public class BitmapFactory { * @return the decoded bitmap, or null */ public static Bitmap decodeFileDescriptor(FileDescriptor fd, Rect outPadding, Options opts) { if (nativeIsSeekable(fd)) { Bitmap bm = nativeDecodeFileDescriptor(fd, outPadding, opts); if (bm == null && opts != null && opts.inBitmap != null) { throw new IllegalArgumentException("Problem decoding into existing bitmap"); } return finishDecode(bm, outPadding, opts); } else { FileInputStream fis = new FileInputStream(fd); try { return decodeStream(fis, outPadding, opts); } finally { try { fis.close(); } catch (Throwable t) {/* ignore */} } } } /** Loading Loading @@ -615,4 +626,5 @@ public class BitmapFactory { private static native Bitmap nativeDecodeByteArray(byte[] data, int offset, int length, Options opts); private static native byte[] nativeScaleNinePatch(byte[] chunk, float scale, Rect pad); private static native boolean nativeIsSeekable(FileDescriptor fd); } Loading
core/jni/android/graphics/BitmapFactory.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -517,6 +517,11 @@ static void nativeSetDefaultConfig(JNIEnv* env, jobject, int nativeConfig) { } } static jboolean nativeIsSeekable(JNIEnv* env, jobject, jobject fileDescriptor) { jint descriptor = env->GetIntField(fileDescriptor, gFileDescriptor_descriptor); return ::lseek64(descriptor, 0, SEEK_CUR) != -1 ? JNI_TRUE : JNI_FALSE; } /////////////////////////////////////////////////////////////////////////////// static JNINativeMethod gMethods[] = { Loading Loading @@ -546,6 +551,11 @@ static JNINativeMethod gMethods[] = { }, { "nativeSetDefaultConfig", "(I)V", (void*)nativeSetDefaultConfig }, { "nativeIsSeekable", "(Ljava/io/FileDescriptor;)Z", (void*)nativeIsSeekable }, }; static JNINativeMethod gOptionsMethods[] = { Loading
graphics/java/android/graphics/BitmapFactory.java +16 −4 Original line number Diff line number Diff line Loading @@ -564,11 +564,22 @@ public class BitmapFactory { * @return the decoded bitmap, or null */ public static Bitmap decodeFileDescriptor(FileDescriptor fd, Rect outPadding, Options opts) { if (nativeIsSeekable(fd)) { Bitmap bm = nativeDecodeFileDescriptor(fd, outPadding, opts); if (bm == null && opts != null && opts.inBitmap != null) { throw new IllegalArgumentException("Problem decoding into existing bitmap"); } return finishDecode(bm, outPadding, opts); } else { FileInputStream fis = new FileInputStream(fd); try { return decodeStream(fis, outPadding, opts); } finally { try { fis.close(); } catch (Throwable t) {/* ignore */} } } } /** Loading Loading @@ -615,4 +626,5 @@ public class BitmapFactory { private static native Bitmap nativeDecodeByteArray(byte[] data, int offset, int length, Options opts); private static native byte[] nativeScaleNinePatch(byte[] chunk, float scale, Rect pad); private static native boolean nativeIsSeekable(FileDescriptor fd); }