Add protect to some Core Graphics methods
This commit is contained in:
parent
2e4266b7db
commit
8a034a403b
|
@ -58,14 +58,7 @@
|
|||
}
|
||||
|
||||
float duration = [self sd_frameDurationAtIndex:i source:source];
|
||||
#if SD_WATCH
|
||||
CGFloat scale = 1;
|
||||
scale = [WKInterfaceDevice currentDevice].screenScale;
|
||||
#elif SD_UIKIT
|
||||
CGFloat scale = 1;
|
||||
scale = [UIScreen mainScreen].scale;
|
||||
#endif
|
||||
UIImage *image = [[UIImage alloc] initWithCGImage:imageRef scale:scale orientation:UIImageOrientationUp];
|
||||
UIImage *image = [[UIImage alloc] initWithCGImage:imageRef];
|
||||
CGImageRelease(imageRef);
|
||||
|
||||
SDWebImageFrame *frame = [SDWebImageFrame frameWithImage:image duration:duration];
|
||||
|
@ -95,6 +88,9 @@
|
|||
- (float)sd_frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source {
|
||||
float frameDuration = 0.1f;
|
||||
CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil);
|
||||
if (!cfFrameProperties) {
|
||||
return frameDuration;
|
||||
}
|
||||
NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties;
|
||||
NSDictionary *gifProperties = frameProperties[(NSString *)kCGImagePropertyGIFDictionary];
|
||||
|
||||
|
|
|
@ -394,6 +394,9 @@
|
|||
|
||||
size_t bytesPerRow = CGImageGetBytesPerRow(imageRef);
|
||||
CGDataProviderRef dataProvider = CGImageGetDataProvider(imageRef);
|
||||
if (!dataProvider) {
|
||||
return nil;
|
||||
}
|
||||
CFDataRef dataRef = CGDataProviderCopyData(dataProvider);
|
||||
uint8_t *rgba = (uint8_t *)CFDataGetBytePtr(dataRef);
|
||||
|
||||
|
|
Loading…
Reference in New Issue