Skip to content

Commit

Permalink
Merged Pull request #80 - resolved conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ebennett-elec committed Jul 18, 2014
1 parent 3581bf9 commit 808ebdb
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 31 deletions.
7 changes: 7 additions & 0 deletions Classes/ELCImagePicker/ELCImagePickerController.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,16 @@
@property (nonatomic, weak) id<ELCImagePickerControllerDelegate> imagePickerDelegate;
@property (nonatomic, assign) NSInteger maximumImagesCount;

/**
* YES if the picker should return a UIImage along with other meta info (this is the default),
* NO if the picker should return the assetURL and other meta info, but no actual UIImage.
*/
@property (nonatomic, assign) BOOL returnsImage;

/**
* YES if the picker should return the original image,
* or NO for an image suitable for displaying full screen on the device.
* Does nothing if `returnsImage` is NO.
*/
@property (nonatomic, assign) BOOL returnsOriginalImage;

Expand Down
35 changes: 19 additions & 16 deletions Classes/ELCImagePicker/ELCImagePickerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ - (id)initImagePicker
self = [super initWithRootViewController:albumPicker];
if (self) {
self.maximumImagesCount = 4;
self.returnsImage = YES;
[albumPicker setParent:self];
}
return self;
Expand All @@ -35,6 +36,7 @@ - (id)initWithRootViewController:(UIViewController *)rootViewController
self = [super initWithRootViewController:rootViewController];
if (self) {
self.maximumImagesCount = 4;
self.returnsImage = YES;
}
return self;
}
Expand Down Expand Up @@ -67,7 +69,6 @@ - (void)selectedAssets:(NSArray *)assets


for(ALAsset *asset in assets) {
@autoreleasepool {
id obj = [asset valueForProperty:ALAssetPropertyType];
if (!obj) {
continue;
Expand All @@ -85,27 +86,29 @@ - (void)selectedAssets:(NSArray *)assets
ALAssetRepresentation *assetRep = [asset defaultRepresentation];

if(assetRep != nil) {
CGImageRef imgRef = nil;
//defaultRepresentation returns image as it appears in photo picker, rotated and sized,
//so use UIImageOrientationUp when creating our image below.
UIImageOrientation orientation = UIImageOrientationUp;
if (_returnsImage) {
CGImageRef imgRef = nil;
//defaultRepresentation returns image as it appears in photo picker, rotated and sized,
//so use UIImageOrientationUp when creating our image below.
UIImageOrientation orientation = UIImageOrientationUp;

if (_returnsOriginalImage) {
imgRef = [assetRep fullResolutionImage];
orientation = [assetRep orientation];
} else {
imgRef = [assetRep fullScreenImage];
if (_returnsOriginalImage) {
imgRef = [assetRep fullResolutionImage];
orientation = [assetRep orientation];
} else {
imgRef = [assetRep fullScreenImage];
}
UIImage *img = [UIImage imageWithCGImage:imgRef
scale:1.0f
orientation:orientation];
[workingDictionary setObject:img forKey:UIImagePickerControllerOriginalImage];
}
UIImage *originalimage = [UIImage imageWithCGImage:imgRef
scale:1.0f
orientation:orientation];
EYLargePhoto* photo=[[EYLargePhotoManager share]saveOriginalImage:originalimage];
[workingDictionary setObject:photo forKey:UIImagePickerControllerOriginalImage];

[workingDictionary setObject:[[asset valueForProperty:ALAssetPropertyURLs] valueForKey:[[[asset valueForProperty:ALAssetPropertyURLs] allKeys] objectAtIndex:0]] forKey:UIImagePickerControllerReferenceURL];

[returnArray addObject:workingDictionary];
}
}

}
if (_imagePickerDelegate != nil && [_imagePickerDelegate respondsToSelector:@selector(elcImagePickerController:didFinishPickingMediaWithInfo:)]) {
[_imagePickerDelegate performSelector:@selector(elcImagePickerController:didFinishPickingMediaWithInfo:) withObject:self withObject:returnArray];
Expand Down
34 changes: 19 additions & 15 deletions Classes/ELCImagePickerDemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,25 @@ - (void)elcImagePickerController:(ELCImagePickerController *)picker didFinishPic
NSMutableArray *images = [NSMutableArray arrayWithCapacity:[info count]];

for (NSDictionary *dict in info) {

// UIImage *originalimage = [dict objectForKey:UIImagePickerControllerOriginalImage];
// UIImage* image=[[EYLargePhotoManager share]saveOriginalImage:originalimage].thumb;
EYLargePhoto *photo = [dict objectForKey:UIImagePickerControllerOriginalImage];
UIImage* image=photo.thumb;
[images addObject:image];

UIImageView *imageview = [[UIImageView alloc] initWithImage:image];
[imageview setContentMode:UIViewContentModeScaleAspectFit];
imageview.frame = workingFrame;

[_scrollView addSubview:imageview];

workingFrame.origin.x = workingFrame.origin.x + workingFrame.size.width;
}
if ([dict objectForKey:UIImagePickerControllerOriginalImage]){
// UIImage *originalimage = [dict objectForKey:UIImagePickerControllerOriginalImage];
// UIImage* image=[[EYLargePhotoManager share]saveOriginalImage:originalimage].thumb;
EYLargePhoto *photo = [[EYLargePhoto alloc] init];
photo.thumb = [dict objectForKey:UIImagePickerControllerOriginalImage];
UIImage* image=photo.thumb;
[images addObject:image];

UIImageView *imageview = [[UIImageView alloc] initWithImage:image];
[imageview setContentMode:UIViewContentModeScaleAspectFit];
imageview.frame = workingFrame;

[_scrollView addSubview:imageview];

workingFrame.origin.x = workingFrame.origin.x + workingFrame.size.width;
} else {
NSLog(@"%@", [dict objectForKey:UIImagePickerControllerReferenceURL]);
}
}

self.chosenImages = images;

Expand Down

0 comments on commit 808ebdb

Please sign in to comment.