@@ -33,15 +33,15 @@ - (void) getPictures:(CDVInvokedUrlCommand *)command {
33
33
34
34
// Create the an album controller and image picker
35
35
ELCAlbumPickerController *albumController = [[ELCAlbumPickerController alloc ] init ];
36
-
36
+
37
37
if (maximumImagesCount == 1 ) {
38
38
albumController.immediateReturn = true ;
39
39
albumController.singleSelection = true ;
40
40
} else {
41
41
albumController.immediateReturn = false ;
42
42
albumController.singleSelection = false ;
43
43
}
44
-
44
+
45
45
ELCImagePickerController *imagePicker = [[ELCImagePickerController alloc ] initWithRootViewController: albumController];
46
46
imagePicker.maximumImagesCount = maximumImagesCount;
47
47
imagePicker.returnsOriginalImage = 1 ;
@@ -75,11 +75,11 @@ - (void)elcImagePickerController:(ELCImagePickerController *)picker didFinishPic
75
75
do {
76
76
filePath = [NSString stringWithFormat: @" %@ /%@ %03d .%@ " , docsPath, CDV_PHOTO_PREFIX, i++, @" jpg" ];
77
77
} while ([fileMgr fileExistsAtPath: filePath]);
78
-
78
+
79
79
@autoreleasepool {
80
80
ALAssetRepresentation *assetRep = [asset defaultRepresentation ];
81
81
CGImageRef imgRef = NULL ;
82
-
82
+
83
83
// defaultRepresentation returns image as it appears in photo picker, rotated and sized,
84
84
// so use UIImageOrientationUp when creating our image below.
85
85
if (picker.returnsOriginalImage ) {
@@ -88,15 +88,15 @@ - (void)elcImagePickerController:(ELCImagePickerController *)picker didFinishPic
88
88
} else {
89
89
imgRef = [assetRep fullScreenImage ];
90
90
}
91
-
91
+
92
92
UIImage* image = [UIImage imageWithCGImage: imgRef scale: 1 .0f orientation: orientation];
93
93
if (self.width == 0 && self.height == 0 ) {
94
94
data = UIImageJPEGRepresentation (image, self.quality /100 .0f );
95
95
} else {
96
96
UIImage* scaledImage = [self imageByScalingNotCroppingForSize: image toSize: targetSize];
97
97
data = UIImageJPEGRepresentation (scaledImage, self.quality /100 .0f );
98
98
}
99
-
99
+
100
100
if (![data writeToFile: filePath options: NSAtomicWrite error: &err]) {
101
101
result = [CDVPluginResult resultWithStatus: CDVCommandStatus_IO_EXCEPTION messageAsString: [err localizedDescription ]];
102
102
break ;
@@ -110,7 +110,7 @@ - (void)elcImagePickerController:(ELCImagePickerController *)picker didFinishPic
110
110
}
111
111
112
112
}
113
-
113
+
114
114
if (nil == result) {
115
115
result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsArray: resultStrings];
116
116
}
@@ -153,7 +153,7 @@ - (UIImage*)imageByScalingNotCroppingForSize:(UIImage*)anImage toSize:(CGSize)fr
153
153
} else {
154
154
scaleFactor = widthFactor; // scale to fit width
155
155
}
156
- scaledSize = CGSizeMake (width * scaleFactor, height * scaleFactor);
156
+ scaledSize = CGSizeMake (floor ( width * scaleFactor), floor ( height * scaleFactor) );
157
157
}
158
158
159
159
UIGraphicsBeginImageContext (scaledSize); // this will resize
0 commit comments