Permalink
Browse files

Add in the ability to select if the imagePicker returns the fullResol…

…utionImage, or the fullScreenImage. #68
  • Loading branch information...
1 parent a408066 commit b108d07d5aecbd92e51d59ed208539224a4de28a James Van Metre committed Dec 16, 2013
View
6 Classes/ELCImagePicker/ELCImagePickerController.h
@@ -35,6 +35,12 @@
@property (nonatomic, weak) id<ELCImagePickerControllerDelegate> imagePickerDelegate;
@property (nonatomic, assign) NSInteger maximumImagesCount;
+/**
+ * YES if the picker should return the original image,
+ * or NO for an image suitable for displaying full screen on the device.
+ */
+@property (nonatomic, assign) BOOL returnsOriginalImage;
+
- (id)initImagePicker;
- (void)cancelImagePicker;
View
14 Classes/ELCImagePicker/ELCImagePickerController.m
@@ -81,14 +81,22 @@ - (void)selectedAssets:(NSArray *)assets
//defaultRepresentation returns image as it appears in photo picker, rotated and sized,
//so use UIImageOrientationUp when creating our image below.
ALAssetRepresentation *assetRep = [asset defaultRepresentation];
+
+ CGImageRef imgRef = nil;
+ UIImageOrientation orientation = UIImageOrientationUp;
- CGImageRef imgRef = [assetRep fullScreenImage];
+ if (_returnsOriginalImage) {
+ imgRef = [assetRep fullResolutionImage];
+ orientation = [assetRep orientation];
+ } else {
+ imgRef = [assetRep fullScreenImage];
+ }
UIImage *img = [UIImage imageWithCGImage:imgRef
scale:1.0f
- orientation:UIImageOrientationUp];
+ orientation:orientation];
[workingDictionary setObject:img forKey:UIImagePickerControllerOriginalImage];
[workingDictionary setObject:[[asset valueForProperty:ALAssetPropertyURLs] valueForKey:[[[asset valueForProperty:ALAssetPropertyURLs] allKeys] objectAtIndex:0]] forKey:UIImagePickerControllerReferenceURL];
-
+
[returnArray addObject:workingDictionary];
}
View
2 Classes/ELCImagePickerDemoViewController.m
@@ -26,6 +26,7 @@ - (IBAction)launchController
{
ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc] initImagePicker];
elcPicker.maximumImagesCount = 4;
+ elcPicker.returnsOriginalImage = NO; //Only return the fullScreenImage, not the fullResolutionImage
elcPicker.imagePickerDelegate = self;
[self presentViewController:elcPicker animated:YES completion:nil];
@@ -64,6 +65,7 @@ - (void)displayPickerForGroup:(ALAssetsGroup *)group
ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc] initWithRootViewController:tablePicker];
elcPicker.maximumImagesCount = 1;
elcPicker.imagePickerDelegate = self;
+ elcPicker.returnsOriginalImage = NO; //Only return the fullScreenImage, not the fullResolutionImage
tablePicker.parent = elcPicker;
// Move me
View
1 README.md
@@ -10,6 +10,7 @@ The image picker is created and displayed in a very similar manner to the `UIIma
// Create the image picker
ELCImagePickerController *imagePicker = [[ELCImagePickerController alloc] initImagePicker];
imagePicker.maximumImagesCount = 4; //Set the maximum number of images to select, defaults to 4
+imagePicker.returnsOriginalImage = NO; //Only return the fullScreenImage, not the fullResolutionImage
imagePicker.imagePickerDelegate = self;
//Present modally

0 comments on commit b108d07

Please sign in to comment.