* fullResolutionUnadjustedImage는 원본 이미지 그대로, fullResolutionAdjustedImage는 필터가 적용된 이미지를 반환한다.
- (UIImage *)_fullResolutionUnadjustedImage { ALAssetRepresentation *representation = [_asset defaultRepresentation]; CGImageRef imageRef = [representation fullResolutionImage]; UIImageOrientation orientation = (UIImageOrientation)representation.orientation; return [UIImage imageWithCGImage:imageRef scale:[representation scale] orientation:orientation]; } - (UIImage *)_fullResolutionAdjustedImage { ALAssetRepresentation *representation = [_asset defaultRepresentation]; // WARNING: This code doesn't work for iOS 8.0+. Use PhotosKit instead. CGImageRef imageRef = [representation fullResolutionImage]; NSString *adjustment = [[representation metadata] objectForKey:@"AdjustmentXMP"]; if (adjustment != nil) { NSData *xmpData = [adjustment dataUsingEncoding:NSUTF8StringEncoding]; CIImage *image = [CIImage imageWithCGImage:imageRef]; NSError *error = nil; NSArray *filterArray = [CIFilter filterArrayFromSerializedXMP:xmpData inputImageExtent:image.extent error:&error]; CIContext *context = [CIContext contextWithOptions:nil]; if (filterArray != nil && !error) { for (CIFilter *filter in filterArray) { [filter setValue:image forKey:kCIInputImageKey]; image = [filter outputImage]; } // TODO: Fix crash when OpenGL calls are made in the background imageRef = [context createCGImage:image fromRect:[image extent]]; } } UIImageOrientation orientation = (UIImageOrientation)representation.orientation; return [UIImage imageWithCGImage:imageRef scale:[representation scale] orientation:orientation]; }
'Mobile Application > iOS' 카테고리의 다른 글
[AssetLibrary] iOS 8.1 이상에서 포토 스트림 지원하기. (0) | 2015.03.04 |
---|---|
[PhotoKit] 카메라 롤과 일반 앨범 가져오기. (0) | 2015.03.01 |
[PhotoKit] 카메라 롤과 일반 앨범 분류하기. (0) | 2015.02.27 |
[PonyDebugger] Server 설치하기 (0) | 2015.02.26 |
[Facebook] Facebook SDK를 이용해서 시스템 설정 기반으로 로그인 하기. (0) | 2015.02.26 |