incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject [2/2] ios commit: iOS camera targetWidth/Height don't match the documentation - changes per shazron
Date Wed, 11 Apr 2012 23:14:19 GMT
iOS camera targetWidth/Height don't match the documentation - changes per shazron


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/837ab699
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/837ab699
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/837ab699

Branch: refs/heads/master
Commit: 837ab699a88a6742781e90db3dbf3742d516b488
Parents: d5f5c39
Author: Ben Birch <bbirch@aconex.com>
Authored: Thu Apr 12 02:22:08 2012 +1000
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Wed Apr 11 16:10:23 2012 -0700

----------------------------------------------------------------------
 CordovaLib/Classes/CDVCamera.h       |    8 +-------
 CordovaLib/Classes/CDVCamera.m       |   14 +++++++-------
 CordovaLib/javascript/cordova.ios.js |   12 ++----------
 3 files changed, 10 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/837ab699/CordovaLib/Classes/CDVCamera.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCamera.h b/CordovaLib/Classes/CDVCamera.h
index 4cdd45f..6d7661d 100644
--- a/CordovaLib/Classes/CDVCamera.h
+++ b/CordovaLib/Classes/CDVCamera.h
@@ -39,12 +39,6 @@ enum CDVMediaType {
 };
 typedef NSUInteger CDVMediaType;
 
-enum CDVSizingMethod {
-		SizingMethodContain = 0,
-		SizingMethodCover
-};
-typedef NSUInteger CDVSizingMethod;
-
 @interface CDVCameraPicker : UIImagePickerController
 {
 }
@@ -59,7 +53,7 @@ typedef NSUInteger CDVSizingMethod;
 @property (assign) CGSize targetSize;
 @property (assign) bool correctOrientation;
 @property (assign) bool saveToPhotoAlbum;
-@property (nonatomic) enum CDVSizingMethod sizingMethod;
+@property (assign) bool cropToSize;
 
 - (void) dealloc;
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/837ab699/CordovaLib/Classes/CDVCamera.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCamera.m b/CordovaLib/Classes/CDVCamera.m
index 3e3f4e0..38c6130 100644
--- a/CordovaLib/Classes/CDVCamera.m
+++ b/CordovaLib/Classes/CDVCamera.m
@@ -44,7 +44,7 @@
  *  8       allowsEdit
  *  9       correctOrientation
  *  10      saveToPhotoAlbum
- *  11	    sizingMethod
+ *  11      cropToSize
  */
 - (void) takePicture:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
 {
@@ -86,7 +86,7 @@
         self.pickerController.allowsEditing = allowEdit; // THIS IS ALL IT TAKES FOR CROPPING
- jm
         self.pickerController.callbackId = callbackId;
         self.pickerController.targetSize = targetSize;
-        self.pickerController.sizingMethod = ([arguments objectAtIndex:11]) ? [[arguments
objectAtIndex:11] intValue ] : SizingMethodContain;
+        self.pickerController.cropToSize = ([arguments objectAtIndex:11]) ? [[arguments objectAtIndex:11]
boolValue ] : false;
         self.pickerController.correctOrientation = [[arguments objectAtIndex:9] boolValue];
         self.pickerController.saveToPhotoAlbum = [[arguments objectAtIndex:10] boolValue];
         
@@ -182,11 +182,11 @@
     UIImage *scaledImage = nil;
     
     if (self.pickerController.targetSize.width > 0 && self.pickerController.targetSize.height
> 0) {
-        // if preventCropping, resize image to fit within targetSize without cropping
-        if(self.pickerController.sizingMethod == SizingMethodContain) {
-            scaledImage = [self imageByScalingNotCroppingForSize:image toSize:self.pickerController.targetSize];
-        } else if(self.pickerController.sizingMethod == SizingMethodCover) {
+        // if cropToSize, resize image and crop to target size, otherwise resize to fit target
without cropping
+        if(self.pickerController.cropToSize) {
             scaledImage = [self imageByScalingAndCroppingForSize:image toSize:self.pickerController.targetSize];
+        } else {
+            scaledImage = [self imageByScalingNotCroppingForSize:image toSize:self.pickerController.targetSize];
         }
     }
     NSData* data = nil;
@@ -472,7 +472,7 @@
 @synthesize correctOrientation;
 @synthesize saveToPhotoAlbum;
 @synthesize encodingType;
-@synthesize sizingMethod;
+@synthesize cropToSize;
 
 
 - (void) dealloc

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/837ab699/CordovaLib/javascript/cordova.ios.js
----------------------------------------------------------------------
diff --git a/CordovaLib/javascript/cordova.ios.js b/CordovaLib/javascript/cordova.ios.js
index 5e54009..9f7cd45 100644
--- a/CordovaLib/javascript/cordova.ios.js
+++ b/CordovaLib/javascript/cordova.ios.js
@@ -1103,17 +1103,13 @@ cameraExport.getPicture = function(successCallback, errorCallback,
options) {
     	correctOrientation = options.correctOrientation <=0 ? false : true;
     }
     var saveToPhotoAlbum = false;
-    if (typeof options.saveToPhotoAlbum == "boolean") {
+	if (typeof options.saveToPhotoAlbum == "boolean") {
     	saveToPhotoAlbum = options.saveToPhotoAlbum;
     } else if (typeof options.saveToPhotoAlbum == "number") {
     	saveToPhotoAlbum = options.saveToPhotoAlbum <=0 ? false : true;
     }
-    var sizingMethod = Camera.ResizingMethod.CONTAIN;
-    if (typeof options.sizingMethod == "number") {
-        sizingMethod = options.sizingMethod;
-    }
 
-    exec(successCallback, errorCallback, "Camera", "takePicture", [quality, destinationType,
sourceType, targetWidth, targetHeight, encodingType, mediaType, allowEdit, correctOrientation,
saveToPhotoAlbum, sizingMethod]);
+    exec(successCallback, errorCallback, "Camera", "takePicture", [quality, destinationType,
sourceType, targetWidth, targetHeight, encodingType, mediaType, allowEdit, correctOrientation,
saveToPhotoAlbum]);
 }
 
 module.exports = cameraExport;
@@ -1140,10 +1136,6 @@ module.exports = {
     PHOTOLIBRARY : 0,    // Choose image from picture library (same as SAVEDPHOTOALBUM for
Android)
     CAMERA : 1,          // Take picture from camera
     SAVEDPHOTOALBUM : 2  // Choose image from picture library (same as PHOTOLIBRARY for Android)
-  },
-  ResizingMethod:{       // the ResizingMethod uses the same resizing algorithm as css3 background-size
rule
-    CONTAIN : 0,         // Scale the image, while preserving its intrinsic aspect ratio,
to the largest size such that both its width and its height can fit inside the targetHeight/Width
-    COVER : 1            // Scale the image, while preserving its intrinsic aspect ratio,
to the smallest size such that both its width and its height can completely cover the targetHeight/Width
   }
 };
 


Mime
View raw message