mirror of
https://gitee.com/shuto/cordova-imagePicker.git
synced 2026-04-16 00:02:54 +08:00
Merge branch 'master' of https://github.com/shanebdavis/cordova-imagePicker
This commit is contained in:
@@ -33,7 +33,7 @@ typedef enum : NSUInteger {
|
||||
|
||||
// Create the an album controller and image picker
|
||||
ELCAlbumPickerController *albumController = [[ELCAlbumPickerController alloc] init];
|
||||
|
||||
|
||||
if (maximumImagesCount == 1) {
|
||||
albumController.immediateReturn = true;
|
||||
albumController.singleSelection = true;
|
||||
@@ -41,7 +41,7 @@ typedef enum : NSUInteger {
|
||||
albumController.immediateReturn = false;
|
||||
albumController.singleSelection = false;
|
||||
}
|
||||
|
||||
|
||||
ELCImagePickerController *imagePicker = [[ELCImagePickerController alloc] initWithRootViewController:albumController];
|
||||
imagePicker.maximumImagesCount = maximumImagesCount;
|
||||
imagePicker.returnsOriginalImage = 1;
|
||||
@@ -75,11 +75,11 @@ typedef enum : NSUInteger {
|
||||
do {
|
||||
filePath = [NSString stringWithFormat:@"%@/%@%03d.%@", docsPath, CDV_PHOTO_PREFIX, i++, @"jpg"];
|
||||
} while ([fileMgr fileExistsAtPath:filePath]);
|
||||
|
||||
|
||||
@autoreleasepool {
|
||||
ALAssetRepresentation *assetRep = [asset defaultRepresentation];
|
||||
CGImageRef imgRef = NULL;
|
||||
|
||||
|
||||
//defaultRepresentation returns image as it appears in photo picker, rotated and sized,
|
||||
//so use UIImageOrientationUp when creating our image below.
|
||||
if (picker.returnsOriginalImage) {
|
||||
@@ -88,7 +88,7 @@ typedef enum : NSUInteger {
|
||||
} else {
|
||||
imgRef = [assetRep fullScreenImage];
|
||||
}
|
||||
|
||||
|
||||
UIImage* image = [UIImage imageWithCGImage:imgRef scale:1.0f orientation:orientation];
|
||||
if (self.width == 0 && self.height == 0) {
|
||||
data = UIImageJPEGRepresentation(image, self.quality/100.0f);
|
||||
@@ -96,7 +96,7 @@ typedef enum : NSUInteger {
|
||||
UIImage* scaledImage = [self imageByScalingNotCroppingForSize:image toSize:targetSize];
|
||||
data = UIImageJPEGRepresentation(scaledImage, self.quality/100.0f);
|
||||
}
|
||||
|
||||
|
||||
if (![data writeToFile:filePath options:NSAtomicWrite error:&err]) {
|
||||
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[err localizedDescription]];
|
||||
break;
|
||||
@@ -110,7 +110,7 @@ typedef enum : NSUInteger {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (nil == result) {
|
||||
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:resultStrings];
|
||||
}
|
||||
@@ -153,7 +153,7 @@ typedef enum : NSUInteger {
|
||||
} else {
|
||||
scaleFactor = widthFactor; // scale to fit width
|
||||
}
|
||||
scaledSize = CGSizeMake(width * scaleFactor, height * scaleFactor);
|
||||
scaledSize = CGSizeMake(floor(width * scaleFactor), floor(height * scaleFactor));
|
||||
}
|
||||
|
||||
UIGraphicsBeginImageContext(scaledSize); // this will resize
|
||||
|
||||
Reference in New Issue
Block a user