You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ja...@apache.org on 2013/08/08 21:17:21 UTC
git commit: [CB-3453] Save original picture to photo library
Updated Branches:
refs/heads/master c1935df8d -> 767e064c0
[CB-3453] Save original picture to photo library
- saves original picture when the following camera options are set for no edits (i.e. allowEdit is false, correctOrientation is false, targetWidth/targetHeight are not specified)
- this mirrors cordova-android behavior
- testing done with mobile-spec auto and manual tests
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/767e064c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/767e064c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/767e064c
Branch: refs/heads/master
Commit: 767e064c01d224b4159dcb292017c8db521afc67
Parents: c1935df
Author: James Jong <wj...@gmail.com>
Authored: Thu Aug 8 15:01:59 2013 -0400
Committer: James Jong <wj...@gmail.com>
Committed: Thu Aug 8 15:01:59 2013 -0400
----------------------------------------------------------------------
src/ios/CDVCamera.m | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/767e064c/src/ios/CDVCamera.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVCamera.m b/src/ios/CDVCamera.m
index 11662ed..ebef288 100644
--- a/src/ios/CDVCamera.m
+++ b/src/ios/CDVCamera.m
@@ -303,11 +303,16 @@ static NSSet* org_apache_cordova_validArrowDirections;
}
NSData* data = nil;
+ // returnedImage is the image that is returned to caller and (optionally) saved to photo album
+ UIImage* returnedImage = (scaledImage == nil ? image : scaledImage);
if (cameraPicker.encodingType == EncodingTypePNG) {
- data = UIImagePNGRepresentation(scaledImage == nil ? image : scaledImage);
+ data = UIImagePNGRepresentation(returnedImage);
+ } else if ((cameraPicker.allowsEditing==false) && (cameraPicker.targetSize.width <= 0) && (cameraPicker.targetSize.height <= 0) && (cameraPicker.correctOrientation==false)){
+ // use image unedited as requested , don't resize
+ data = UIImageJPEGRepresentation(returnedImage, 1.0);
} else {
- data = UIImageJPEGRepresentation(scaledImage == nil ? image : scaledImage, cameraPicker.quality / 100.0f);
+ data = UIImageJPEGRepresentation(returnedImage, cameraPicker.quality / 100.0f);
NSDictionary *controllerMetadata = [info objectForKey:@"UIImagePickerControllerMediaMetadata"];
if (controllerMetadata) {
@@ -323,7 +328,8 @@ static NSSet* org_apache_cordova_validArrowDirections;
}
if (cameraPicker.saveToPhotoAlbum) {
- UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:data], nil, nil, nil);
+ ALAssetsLibrary *library = [ALAssetsLibrary new];
+ [library writeImageToSavedPhotosAlbum:returnedImage.CGImage orientation:(ALAssetOrientation)(returnedImage.imageOrientation) completionBlock:nil];
}
if (cameraPicker.returnType == DestinationTypeFileUri) {