use Photos framework to export xmp data into the iOS Photo Gallery

This commit is contained in:
2017-09-30 23:24:00 +01:00
parent ccde247f2a
commit 9ec1768acc
3 changed files with 19 additions and 4 deletions

View File

@@ -4,6 +4,7 @@
#ifdef __APPLE__
#include <Foundation/Foundation.h>
#import <Photos/Photos.h>
#endif
@@ -837,8 +838,18 @@ void ui::Canvas::export_equirectangular(std::string data_path)
inject_xmp(name);
//int ret = stbi_write_png(name, m_latlong.getWidth(), m_latlong.getHeight(), 4, latlong_data.get(), m_latlong.stride());
#ifdef __IOS__
image = [UIImage imageWithContentsOfFile:[NSString stringWithUTF8String:name]];
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
NSURL* url = [NSURL fileURLWithPath:[NSString stringWithUTF8String:name]];
PHAssetChangeRequest *changeRequest = [PHAssetChangeRequest creationRequestForAssetFromImageAtFileURL:url];
changeRequest.creationDate = [NSDate date];
} completionHandler:^(BOOL success, NSError *error) {
if (success) {
NSLog(@"successfully saved");
}
else {
NSLog(@"error saving to photos: %@", error);
}
}];
#endif
}