Fix for sideways images from camera on iOS 4.x #17

Merged
merged 1 commit into from Mar 26, 2013
View
7 Classes/ELCImagePickerController.m
@@ -30,7 +30,12 @@ -(void)selectedAssets:(NSArray*)_assets {
NSMutableDictionary *workingDictionary = [[NSMutableDictionary alloc] init];
[workingDictionary setObject:[asset valueForProperty:ALAssetPropertyType] forKey:@"UIImagePickerControllerMediaType"];
- [workingDictionary setObject:[UIImage imageWithCGImage:[[asset defaultRepresentation] fullScreenImage]] forKey:@"UIImagePickerControllerOriginalImage"];
+ ALAssetRepresentation *assetRep = [asset defaultRepresentation];
+ CGImageRef imgRef = [assetRep fullScreenImage];
+ UIImage *img = [UIImage imageWithCGImage:imgRef
+ scale:assetRep.scale
+ orientation:(UIImageOrientation)assetRep.orientation];
+ [workingDictionary setObject:img forKey:@"UIImagePickerControllerOriginalImage"];
[workingDictionary setObject:[[asset valueForProperty:ALAssetPropertyURLs] valueForKey:[[[asset valueForProperty:ALAssetPropertyURLs] allKeys] objectAtIndex:0]] forKey:@"UIImagePickerControllerReferenceURL"];
[returnArray addObject:workingDictionary];