gpt4 book ai didi

ios - 如何在 iOS 10 中导出 Apple 新的 RAW 照片格式 .dng?

转载 作者:行者123 更新时间:2023-11-29 00:42:29 26 4
gpt4 key购买 nike

我在导出 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");
}
}
}
}];
}];

关于ios - 如何在 iOS 10 中导出 Apple 新的 RAW 照片格式 .dng?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39116765/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com