0
Apple의 새로운 RAW 사진 형식 .dng을 내보내는 데 문제가 있습니다.iOS 10에서 Apple의 새로운 RAW 사진 형식 .dng을 내보내는 방법은 무엇입니까?
UIActivityViewController는 사진을 JPEG로 내 보냅니다.
도움을 주시면 감사하겠습니다.
Apple의 새로운 RAW 사진 형식 .dng을 내보내는 데 문제가 있습니다.iOS 10에서 Apple의 새로운 RAW 사진 형식 .dng을 내보내는 방법은 무엇입니까?
UIActivityViewController는 사진을 JPEG로 내 보냅니다.
도움을 주시면 감사하겠습니다.
다음은 문제를 해결 한 방법입니다.
-(void)activityAction{
PHAsset *asset = self.assetsFetchResults[(int)self.image_number];
PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init];
options.synchronous = NO;
options.version = PHImageRequestOptionsVersionCurrent;
options.deliveryMode = PHImageRequestOptionsDeliveryModeOpportunistic;
options.resizeMode = PHImageRequestOptionsResizeModeNone;
options.networkAccessAllowed = NO;//HAS TO BE YES TO DOWNLOAD FROM THE CLOUD AND PROGRESS TO SHOW
/*options.progressHandler = ^(double progress,NSError *error,BOOL* stop, NSDictionary* dict) {
NSLog(@"progress %lf",progress); //never gets called
};*/
[[PHImageManager defaultManager] requestImageDataForAsset:asset options:options resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation imageOrientation, NSDictionary *info){
NSURL *assetURL = [info objectForKey:@"PHImageFileURLKey"];
NSString *photoFormat = [assetURL pathExtension];
NSURL *temporaryDNGFileURL;
NSArray *activityItems;
if([photoFormat isEqualToString:@"DNG"] && [[UIDevice currentDevice].systemVersion floatValue] >= 10){
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSDateFormatter *format = [[NSDateFormatter alloc] init];
[format setDateFormat:@"MMddyyyyHHmmss"];
NSString *assetDateString = [format stringFromDate:[NSDate date]];
NSString *assetPath = [documentsDirectory stringByAppendingPathComponent:[assetDateString stringByAppendingString:@".dng"]];
temporaryDNGFileURL = [NSURL fileURLWithPath:assetPath];
[imageData writeToURL:temporaryDNGFileURL atomically:YES];
activityItems = @[temporaryDNGFileURL];
}
else{
UIImage *shareImage = [[UIImage alloc] initWithData:imageData];
activityItems = @[shareImage];
}
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
activityVC.excludedActivityTypes = @[UIActivityTypeSaveToCameraRoll];
activityVC.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:activityVC animated:YES completion:nil];
[activityVC setCompletionWithItemsHandler:^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) {
NSString *ServiceMsg = nil;
if([activityType isEqualToString:UIActivityTypeMail]) ServiceMsg = @"Mail Done";
if([activityType isEqualToString:UIActivityTypeMessage]) ServiceMsg = @"Message Done";
if([activityType isEqualToString:UIActivityTypeAirDrop]) ServiceMsg = @"AirDrop Done";
if([activityType isEqualToString:UIActivityTypePostToTwitter]) ServiceMsg = @"Twitter Done";
if([activityType isEqualToString:UIActivityTypePostToFacebook]) ServiceMsg = @"Facebook Done";
if([activityType isEqualToString:UIActivityTypePostToFlickr]) ServiceMsg = @"Flickr Done";
if([activityType isEqualToString:UIActivityTypePostToTencentWeibo]) ServiceMsg = @"Weibo Done";
if(completed){
[customActivityActionPressedTimer invalidate];
customActivityActionPressedTimer = nil;
customActivityAction = 0;
[[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"customActivityAction"];
NSLog(@"ACTIVITY VIEW DONE");
if([[NSFileManager defaultManager] fileExistsAtPath:temporaryDNGFileURL.path]){
NSError *error;
[[NSFileManager defaultManager] removeItemAtPath:temporaryDNGFileURL.path error:&error];
if(error){
NSLog(@"RAW DNG FILE DELETE FAILED");
}
else{
NSLog(@"RAW DNG FILE DELETED");
}
}
}
else{
[customActivityActionPressedTimer invalidate];
customActivityActionPressedTimer = nil;
customActivityAction = 0;
[[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"customActivityAction"];
NSLog(@"ACTIVITY VIEW CANCEL");
if([[NSFileManager defaultManager] fileExistsAtPath:temporaryDNGFileURL.path]){
NSError *error;
[[NSFileManager defaultManager] removeItemAtPath:temporaryDNGFileURL.path error:&error];
if(error){
NSLog(@"RAW DNG FILE DELETE FAILED");
}
else{
NSLog(@"RAW DNG FILE DELETED");
}
}
}
}];
}];
}