Removed need for getFormatData/Image to load image into memory

This commit is contained in:
macdonst 2012-06-13 15:57:17 -04:00
parent 56047e5fc8
commit 34820f4344

View File

@ -156,10 +156,11 @@ public class Capture extends Plugin {
* @throws JSONException * @throws JSONException
*/ */
private JSONObject getImageData(String filePath, JSONObject obj) throws JSONException { private JSONObject getImageData(String filePath, JSONObject obj) throws JSONException {
Bitmap bitmap = BitmapFactory.decodeFile(FileUtils.stripFileProtocol(filePath)); BitmapFactory.Options options = new BitmapFactory.Options();
obj.put("height", bitmap.getHeight()); options.inJustDecodeBounds = true;
obj.put("width", bitmap.getWidth()); BitmapFactory.decodeFile(FileUtils.stripFileProtocol(filePath), options);
bitmap.recycle(); obj.put("height", options.outHeight);
obj.put("width", options.outWidth);
return obj; return obj;
} }
@ -362,8 +363,8 @@ public class Capture extends Plugin {
// File properties // File properties
obj.put("name", fp.getName()); obj.put("name", fp.getName());
obj.put("fullPath", "file://" + fp.getAbsolutePath()); obj.put("fullPath", "file://" + fp.getAbsolutePath());
// Because of an issue with MimeTypeMap.getMimeTypeFromExtension() all .3gpp files // 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 // 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. // is stored in the audio or video content store.
if (fp.getAbsoluteFile().toString().endsWith(".3gp") || fp.getAbsoluteFile().toString().endsWith(".3gpp")) { if (fp.getAbsoluteFile().toString().endsWith(".3gp") || fp.getAbsoluteFile().toString().endsWith(".3gpp")) {
if (data.toString().contains("/audio/")) { if (data.toString().contains("/audio/")) {