Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Merged
merged 1 commit into from

2 participants

@thedarkbark

Previous to iOS 5, the fullScreenImage method of ALAssetRepresentation
doesn't return a correctly oriented CGImage, so the UIImage has to be
created with specified scale and orientation to prevent sideways and
upside-down images on iOS 4 devices.

@thedarkbark thedarkbark Orientation fix
Previous to iOS 5, the fullScreenImage method of ALAssetRepresentation
doesn't return a correctly oriented CGImage, so the UIImage has to be
created with specified scale and orientation to prevent sideways and
upside-down images on iOS 4 devices.
f87cfcd
@OpenFibers OpenFibers referenced this pull request from a commit in OpenFibers/ELCImagePickerController
@OpenFibers OpenFibers merged pull request #17 from thedarkbark f6e83d1
@jvanmetre jvanmetre merged commit 8052a42 into B-Sides:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 16, 2012
  1. @thedarkbark

    Orientation fix

    thedarkbark authored
    Previous to iOS 5, the fullScreenImage method of ALAssetRepresentation
    doesn't return a correctly oriented CGImage, so the UIImage has to be
    created with specified scale and orientation to prevent sideways and
    upside-down images on iOS 4 devices.
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 1 deletion.
  1. +6 −1 Classes/ELCImagePickerController.m
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];
Something went wrong with that request. Please try again.