From adfdb16dc5a726ac83d30b6b9daf61ab7c1129df Mon Sep 17 00:00:00 2001 From: macdonst Date: Tue, 5 Jun 2012 08:42:17 -0400 Subject: [PATCH] CB-860: MediaFile.getFormatData broken for Image from Capture --- framework/src/org/apache/cordova/Capture.java | 3 ++- framework/src/org/apache/cordova/FileUtils.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/framework/src/org/apache/cordova/Capture.java b/framework/src/org/apache/cordova/Capture.java index 9809ed11..1eb0b90f 100644 --- a/framework/src/org/apache/cordova/Capture.java +++ b/framework/src/org/apache/cordova/Capture.java @@ -148,9 +148,10 @@ public class Capture extends Plugin { * @throws JSONException */ private JSONObject getImageData(String filePath, JSONObject obj) throws JSONException { - Bitmap bitmap = BitmapFactory.decodeFile(filePath); + Bitmap bitmap = BitmapFactory.decodeFile(FileUtils.stripFileProtocol(filePath)); obj.put("height", bitmap.getHeight()); obj.put("width", bitmap.getWidth()); + bitmap.recycle(); return obj; } diff --git a/framework/src/org/apache/cordova/FileUtils.java b/framework/src/org/apache/cordova/FileUtils.java index c7d02804..32d36784 100755 --- a/framework/src/org/apache/cordova/FileUtils.java +++ b/framework/src/org/apache/cordova/FileUtils.java @@ -740,7 +740,7 @@ public class FileUtils extends Plugin { * @param filePath to be checked. * @return */ - private String stripFileProtocol(String filePath) { + public static String stripFileProtocol(String filePath) { if (filePath.startsWith("file://")) { filePath = filePath.substring(7); }