You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2012/06/13 21:57:33 UTC

android commit: Removed need for getFormatData/Image to load image into memory

Updated Branches:
  refs/heads/master 56047e5fc -> 34820f434


Removed need for getFormatData/Image to load image into memory


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/34820f43
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/34820f43
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/34820f43

Branch: refs/heads/master
Commit: 34820f4344d825930b8d2f247046280226e0e0eb
Parents: 56047e5
Author: macdonst <si...@gmail.com>
Authored: Wed Jun 13 15:57:17 2012 -0400
Committer: macdonst <si...@gmail.com>
Committed: Wed Jun 13 15:57:17 2012 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/Capture.java |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/34820f43/framework/src/org/apache/cordova/Capture.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/Capture.java b/framework/src/org/apache/cordova/Capture.java
index c6f8202..6e87f1e 100644
--- a/framework/src/org/apache/cordova/Capture.java
+++ b/framework/src/org/apache/cordova/Capture.java
@@ -156,10 +156,11 @@ public class Capture extends Plugin {
      * @throws JSONException
      */
     private JSONObject getImageData(String filePath, JSONObject obj) throws JSONException {
-        Bitmap bitmap = BitmapFactory.decodeFile(FileUtils.stripFileProtocol(filePath));
-        obj.put("height", bitmap.getHeight());
-        obj.put("width", bitmap.getWidth());
-        bitmap.recycle();
+        BitmapFactory.Options options = new BitmapFactory.Options();
+        options.inJustDecodeBounds = true;
+        BitmapFactory.decodeFile(FileUtils.stripFileProtocol(filePath), options);
+        obj.put("height", options.outHeight);
+        obj.put("width", options.outWidth);
         return obj;
     }
 
@@ -362,8 +363,8 @@ public class Capture extends Plugin {
             // File properties
             obj.put("name", fp.getName());
             obj.put("fullPath", "file://" + fp.getAbsolutePath());
-            // Because of an issue with MimeTypeMap.getMimeTypeFromExtension() all .3gpp files 
-            // are reported as video/3gpp. I'm doing this hacky check of the URI to see if it 
+            // Because of an issue with MimeTypeMap.getMimeTypeFromExtension() all .3gpp files
+            // are reported as video/3gpp. I'm doing this hacky check of the URI to see if it
             // is stored in the audio or video content store.
             if (fp.getAbsoluteFile().toString().endsWith(".3gp") || fp.getAbsoluteFile().toString().endsWith(".3gpp")) {
                 if (data.toString().contains("/audio/")) {