You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2014/10/07 21:56:05 UTC
git commit: Pass uri to crop instead of pulling the low resolution
image out of the intent return (close #43)
Repository: cordova-plugin-camera
Updated Branches:
refs/heads/master 03fade661 -> 8b8db828f
Pass uri to crop instead of pulling the low resolution image out of the intent return (close #43)
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/8b8db828
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/8b8db828
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/8b8db828
Branch: refs/heads/master
Commit: 8b8db828f6661ebe8cf44f488140774b9ddd7eb0
Parents: 03fade6
Author: Brian Bolton <br...@laser2mail.com>
Authored: Fri Aug 22 14:48:13 2014 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Oct 7 15:47:04 2014 -0400
----------------------------------------------------------------------
src/android/CameraLauncher.java | 37 +++++++-----------------------------
1 file changed, 7 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/8b8db828/src/android/CameraLauncher.java
----------------------------------------------------------------------
diff --git a/src/android/CameraLauncher.java b/src/android/CameraLauncher.java
index cd15e06..b5574ab 100644
--- a/src/android/CameraLauncher.java
+++ b/src/android/CameraLauncher.java
@@ -314,8 +314,10 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
cropIntent.putExtra("aspectX", 1);
cropIntent.putExtra("aspectY", 1);
}
- // retrieve data on return
- cropIntent.putExtra("return-data", true);
+ // create new file handle to get full resolution crop
+ croppedUri = Uri.fromFile(new File(getTempDirectoryPath(), System.currentTimeMillis() + ".jpg"));
+ cropIntent.putExtra("output", croppedUri);
+
// start the activity - we handle returning in onActivityResult
if (this.cordova != null) {
@@ -584,36 +586,11 @@ private String ouputModifiedBitmap(Bitmap bitmap, Uri uri) throws IOException {
// if camera crop
if (requestCode == CROP_CAMERA) {
if (resultCode == Activity.RESULT_OK) {
- // // get the returned data
- Bundle extras = intent.getExtras();
- // get the cropped bitmap
- Bitmap thePic = extras.getParcelable("data");
- if (thePic == null) {
- this.failPicture("Crop returned no data.");
- return;
- }
-
- // now save the bitmap to a file
- OutputStream fOut = null;
- File temp_file = new File(getTempDirectoryPath(),
- System.currentTimeMillis() + ".jpg");
- try {
- temp_file.createNewFile();
- fOut = new FileOutputStream(temp_file);
- thePic.compress(Bitmap.CompressFormat.JPEG, this.mQuality,
- fOut);
- fOut.flush();
- fOut.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
// // Send Uri back to JavaScript for viewing image
this.callbackContext
- .success(Uri.fromFile(temp_file).toString());
-
+ .success(croppedUri.toString());
+ croppedUri = null;
+
}// If cancelled
else if (resultCode == Activity.RESULT_CANCELED) {
this.failPicture("Camera cancelled.");
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org