Compare commits

...

1 Commits

Author SHA1 Message Date
Michael Kirk
f1abb5703f catalyst compat 2020-02-27 14:15:19 -07:00
3 changed files with 34 additions and 29 deletions

View File

@ -17,7 +17,10 @@ Pod::Spec.new do |s|
core.source_files = 'YYImage/*.{h,m}'
core.public_header_files = 'YYImage/*.{h}'
core.libraries = 'z'
core.frameworks = 'UIKit', 'CoreFoundation', 'QuartzCore', 'AssetsLibrary', 'ImageIO', 'Accelerate', 'MobileCoreServices'
core.frameworks = 'UIKit', 'CoreFoundation', 'QuartzCore', 'ImageIO', 'Accelerate', 'MobileCoreServices'
# CATALYST TODO: How to include a framework only on *non* catalyst (iOS only) targets?
# or, for our purposes we can just exclude it altogether since we're not using it
# core.ios.frameworks = 'AssetLibrary'
end
s.subspec 'WebP' do |webp|

View File

@ -323,18 +323,18 @@ typedef NS_ENUM(NSUInteger, YYImageBlendOperation) {
*/
@property (nonatomic) BOOL yy_isDecodedForDisplay;
/**
Saves this image to iOS Photos Album.
@discussion This method attempts to save the original data to album if the
image is created from an animated GIF/APNG, otherwise, it will save the image
as JPEG or PNG (based on the alpha information).
@param completionBlock The block invoked (in main thread) after the save operation completes.
assetURL: An URL that identifies the saved image file. If the image is not saved, assetURL is nil.
error: If the image is not saved, an error object that describes the reason for failure, otherwise nil.
*/
- (void)yy_saveToAlbumWithCompletionBlock:(nullable void(^)(NSURL * _Nullable assetURL, NSError * _Nullable error))completionBlock;
///**
// Saves this image to iOS Photos Album.
//
// @discussion This method attempts to save the original data to album if the
// image is created from an animated GIF/APNG, otherwise, it will save the image
// as JPEG or PNG (based on the alpha information).
//
// @param completionBlock The block invoked (in main thread) after the save operation completes.
// assetURL: An URL that identifies the saved image file. If the image is not saved, assetURL is nil.
// error: If the image is not saved, an error object that describes the reason for failure, otherwise nil.
// */
//- (void)yy_saveToAlbumWithCompletionBlock:(nullable void(^)(NSURL * _Nullable assetURL, NSError * _Nullable error))completionBlock;
/**
Return a 'best' data representation for this image.

View File

@ -16,7 +16,9 @@
#import <Accelerate/Accelerate.h>
#import <QuartzCore/QuartzCore.h>
#import <MobileCoreServices/MobileCoreServices.h>
#if !TARGET_OS_MACCATALYST
#import <AssetsLibrary/AssetsLibrary.h>
#endif
#import <objc/runtime.h>
#import <pthread.h>
#import <zlib.h>
@ -2792,22 +2794,22 @@ CGImageRef YYCGImageCreateWithWebPData(CFDataRef webpData,
objc_setAssociatedObject(self, @selector(yy_isDecodedForDisplay), @(isDecodedForDisplay), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (void)yy_saveToAlbumWithCompletionBlock:(void(^)(NSURL *assetURL, NSError *error))completionBlock {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSData *data = [self _yy_dataRepresentationForSystem:YES];
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library writeImageDataToSavedPhotosAlbum:data metadata:nil completionBlock:^(NSURL *assetURL, NSError *error){
if (!completionBlock) return;
if (pthread_main_np()) {
completionBlock(assetURL, error);
} else {
dispatch_async(dispatch_get_main_queue(), ^{
completionBlock(assetURL, error);
});
}
}];
});
}
//- (void)yy_saveToAlbumWithCompletionBlock:(void(^)(NSURL *assetURL, NSError *error))completionBlock {
// dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// NSData *data = [self _yy_dataRepresentationForSystem:YES];
// ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
// [library writeImageDataToSavedPhotosAlbum:data metadata:nil completionBlock:^(NSURL *assetURL, NSError *error){
// if (!completionBlock) return;
// if (pthread_main_np()) {
// completionBlock(assetURL, error);
// } else {
// dispatch_async(dispatch_get_main_queue(), ^{
// completionBlock(assetURL, error);
// });
// }
// }];
// });
//}
- (NSData *)yy_imageDataRepresentation {
return [self _yy_dataRepresentationForSystem:NO];