mirror of
https://gitee.com/shuto/cordova-imagePicker.git
synced 2026-05-23 00:05:03 +08:00
fixed bug where some images got a white line on the right or bottom. (ex: 1500x1001 pixel image gets a white line on the bottom)
This commit is contained in:
+8
-8
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
// Create the an album controller and image picker
|
// Create the an album controller and image picker
|
||||||
ELCAlbumPickerController *albumController = [[ELCAlbumPickerController alloc] init];
|
ELCAlbumPickerController *albumController = [[ELCAlbumPickerController alloc] init];
|
||||||
|
|
||||||
if (maximumImagesCount == 1) {
|
if (maximumImagesCount == 1) {
|
||||||
albumController.immediateReturn = true;
|
albumController.immediateReturn = true;
|
||||||
albumController.singleSelection = true;
|
albumController.singleSelection = true;
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
albumController.immediateReturn = false;
|
albumController.immediateReturn = false;
|
||||||
albumController.singleSelection = false;
|
albumController.singleSelection = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ELCImagePickerController *imagePicker = [[ELCImagePickerController alloc] initWithRootViewController:albumController];
|
ELCImagePickerController *imagePicker = [[ELCImagePickerController alloc] initWithRootViewController:albumController];
|
||||||
imagePicker.maximumImagesCount = maximumImagesCount;
|
imagePicker.maximumImagesCount = maximumImagesCount;
|
||||||
imagePicker.returnsOriginalImage = 1;
|
imagePicker.returnsOriginalImage = 1;
|
||||||
@@ -69,11 +69,11 @@
|
|||||||
do {
|
do {
|
||||||
filePath = [NSString stringWithFormat:@"%@/%@%03d.%@", docsPath, CDV_PHOTO_PREFIX, i++, @"jpg"];
|
filePath = [NSString stringWithFormat:@"%@/%@%03d.%@", docsPath, CDV_PHOTO_PREFIX, i++, @"jpg"];
|
||||||
} while ([fileMgr fileExistsAtPath:filePath]);
|
} while ([fileMgr fileExistsAtPath:filePath]);
|
||||||
|
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
ALAssetRepresentation *assetRep = [asset defaultRepresentation];
|
ALAssetRepresentation *assetRep = [asset defaultRepresentation];
|
||||||
CGImageRef imgRef = NULL;
|
CGImageRef imgRef = NULL;
|
||||||
|
|
||||||
//defaultRepresentation returns image as it appears in photo picker, rotated and sized,
|
//defaultRepresentation returns image as it appears in photo picker, rotated and sized,
|
||||||
//so use UIImageOrientationUp when creating our image below.
|
//so use UIImageOrientationUp when creating our image below.
|
||||||
if (picker.returnsOriginalImage) {
|
if (picker.returnsOriginalImage) {
|
||||||
@@ -82,7 +82,7 @@
|
|||||||
} else {
|
} else {
|
||||||
imgRef = [assetRep fullScreenImage];
|
imgRef = [assetRep fullScreenImage];
|
||||||
}
|
}
|
||||||
|
|
||||||
UIImage* image = [UIImage imageWithCGImage:imgRef scale:1.0f orientation:orientation];
|
UIImage* image = [UIImage imageWithCGImage:imgRef scale:1.0f orientation:orientation];
|
||||||
if (self.width == 0 && self.height == 0) {
|
if (self.width == 0 && self.height == 0) {
|
||||||
data = UIImageJPEGRepresentation(image, self.quality/100.0f);
|
data = UIImageJPEGRepresentation(image, self.quality/100.0f);
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
UIImage* scaledImage = [self imageByScalingNotCroppingForSize:image toSize:targetSize];
|
UIImage* scaledImage = [self imageByScalingNotCroppingForSize:image toSize:targetSize];
|
||||||
data = UIImageJPEGRepresentation(scaledImage, self.quality/100.0f);
|
data = UIImageJPEGRepresentation(scaledImage, self.quality/100.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (![data writeToFile:filePath options:NSAtomicWrite error:&err]) {
|
if (![data writeToFile:filePath options:NSAtomicWrite error:&err]) {
|
||||||
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[err localizedDescription]];
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[err localizedDescription]];
|
||||||
break;
|
break;
|
||||||
@@ -100,7 +100,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nil == result) {
|
if (nil == result) {
|
||||||
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:resultStrings];
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:resultStrings];
|
||||||
}
|
}
|
||||||
@@ -143,7 +143,7 @@
|
|||||||
} else {
|
} else {
|
||||||
scaleFactor = widthFactor; // scale to fit width
|
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
|
UIGraphicsBeginImageContext(scaledSize); // this will resize
|
||||||
|
|||||||
Reference in New Issue
Block a user