diff options
author | Marco Nelissen <marcone@google.com> | 2009-06-17 14:06:15 -0700 |
---|---|---|
committer | Marco Nelissen <marcone@google.com> | 2009-06-17 14:07:53 -0700 |
commit | 984b5df3830fe26a45bee39c7e8dd86714c99ed0 (patch) | |
tree | 4bba363edf33de0fe50d60c84e78b071b0c60efa /graphics | |
parent | 9d044514f7777cd42776b7c5251ea83dc4e97931 (diff) | |
download | frameworks_base-984b5df3830fe26a45bee39c7e8dd86714c99ed0.zip frameworks_base-984b5df3830fe26a45bee39c7e8dd86714c99ed0.tar.gz frameworks_base-984b5df3830fe26a45bee39c7e8dd86714c99ed0.tar.bz2 |
Add support to BitmapFactory for decoding a bitmap from a MemoryFile FileDescriptor.
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/graphics/BitmapFactory.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/graphics/java/android/graphics/BitmapFactory.java b/graphics/java/android/graphics/BitmapFactory.java index e5a9aab..2a39987 100644 --- a/graphics/java/android/graphics/BitmapFactory.java +++ b/graphics/java/android/graphics/BitmapFactory.java @@ -18,6 +18,7 @@ package android.graphics; import android.content.res.AssetManager; import android.content.res.Resources; +import android.os.MemoryFile; import android.util.DisplayMetrics; import android.util.TypedValue; @@ -435,6 +436,17 @@ public class BitmapFactory { * @return the decoded bitmap, or null */ public static Bitmap decodeFileDescriptor(FileDescriptor fd, Rect outPadding, Options opts) { + try { + if (MemoryFile.isMemoryFile(fd)) { + int mappedlength = MemoryFile.getMappedSize(fd); + MemoryFile file = new MemoryFile(fd, mappedlength, "r"); + InputStream is = file.getInputStream(); + return decodeStream(is, outPadding, opts); + } + } catch (IOException ex) { + // invalid filedescriptor, no need to call nativeDecodeFileDescriptor() + return null; + } return nativeDecodeFileDescriptor(fd, outPadding, opts); } @@ -447,7 +459,7 @@ public class BitmapFactory { * @return the decoded bitmap, or null */ public static Bitmap decodeFileDescriptor(FileDescriptor fd) { - return nativeDecodeFileDescriptor(fd, null, null); + return decodeFileDescriptor(fd, null, null); } private static native Bitmap nativeDecodeStream(InputStream is, byte[] storage, |