Merge pull request #2392 from zhongwuzw/fix-cfstring-ownership
Replace __bridge_transfer with __bridge when convert from CFStringRef to NSString
This commit is contained in:
commit
cfb830d582
|
@ -139,9 +139,9 @@ const CFStringRef kCGImagePropertyAPNGUnclampedDelayTime = (__bridge CFStringRef
|
||||||
- (NSUInteger)sd_imageLoopCountWithSource:(CGImageSourceRef)source {
|
- (NSUInteger)sd_imageLoopCountWithSource:(CGImageSourceRef)source {
|
||||||
NSUInteger loopCount = 0;
|
NSUInteger loopCount = 0;
|
||||||
NSDictionary *imageProperties = (__bridge_transfer NSDictionary *)CGImageSourceCopyProperties(source, nil);
|
NSDictionary *imageProperties = (__bridge_transfer NSDictionary *)CGImageSourceCopyProperties(source, nil);
|
||||||
NSDictionary *pngProperties = [imageProperties valueForKey:(__bridge_transfer NSString *)kCGImagePropertyPNGDictionary];
|
NSDictionary *pngProperties = [imageProperties valueForKey:(__bridge NSString *)kCGImagePropertyPNGDictionary];
|
||||||
if (pngProperties) {
|
if (pngProperties) {
|
||||||
NSNumber *apngLoopCount = [pngProperties valueForKey:(__bridge_transfer NSString *)kCGImagePropertyAPNGLoopCount];
|
NSNumber *apngLoopCount = [pngProperties valueForKey:(__bridge NSString *)kCGImagePropertyAPNGLoopCount];
|
||||||
if (apngLoopCount != nil) {
|
if (apngLoopCount != nil) {
|
||||||
loopCount = apngLoopCount.unsignedIntegerValue;
|
loopCount = apngLoopCount.unsignedIntegerValue;
|
||||||
}
|
}
|
||||||
|
@ -155,11 +155,11 @@ const CFStringRef kCGImagePropertyAPNGUnclampedDelayTime = (__bridge CFStringRef
|
||||||
NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties;
|
NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties;
|
||||||
NSDictionary *pngProperties = frameProperties[(NSString *)kCGImagePropertyPNGDictionary];
|
NSDictionary *pngProperties = frameProperties[(NSString *)kCGImagePropertyPNGDictionary];
|
||||||
|
|
||||||
NSNumber *delayTimeUnclampedProp = pngProperties[(__bridge_transfer NSString *)kCGImagePropertyAPNGUnclampedDelayTime];
|
NSNumber *delayTimeUnclampedProp = pngProperties[(__bridge NSString *)kCGImagePropertyAPNGUnclampedDelayTime];
|
||||||
if (delayTimeUnclampedProp != nil) {
|
if (delayTimeUnclampedProp != nil) {
|
||||||
frameDuration = [delayTimeUnclampedProp floatValue];
|
frameDuration = [delayTimeUnclampedProp floatValue];
|
||||||
} else {
|
} else {
|
||||||
NSNumber *delayTimeProp = pngProperties[(__bridge_transfer NSString *)kCGImagePropertyAPNGDelayTime];
|
NSNumber *delayTimeProp = pngProperties[(__bridge NSString *)kCGImagePropertyAPNGDelayTime];
|
||||||
if (delayTimeProp != nil) {
|
if (delayTimeProp != nil) {
|
||||||
frameDuration = [delayTimeProp floatValue];
|
frameDuration = [delayTimeProp floatValue];
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@ const CFStringRef kCGImagePropertyAPNGUnclampedDelayTime = (__bridge CFStringRef
|
||||||
if ([options valueForKey:SDImageCoderEncodeCompressionQuality]) {
|
if ([options valueForKey:SDImageCoderEncodeCompressionQuality]) {
|
||||||
compressionQuality = [[options valueForKey:SDImageCoderEncodeCompressionQuality] doubleValue];
|
compressionQuality = [[options valueForKey:SDImageCoderEncodeCompressionQuality] doubleValue];
|
||||||
}
|
}
|
||||||
[properties setValue:@(compressionQuality) forKey:(__bridge_transfer NSString *)kCGImageDestinationLossyCompressionQuality];
|
[properties setValue:@(compressionQuality) forKey:(__bridge NSString *)kCGImageDestinationLossyCompressionQuality];
|
||||||
|
|
||||||
BOOL encodeFirstFrame = [options[SDImageCoderEncodeFirstFrameOnly] boolValue];
|
BOOL encodeFirstFrame = [options[SDImageCoderEncodeFirstFrameOnly] boolValue];
|
||||||
if (encodeFirstFrame || frames.count == 0) {
|
if (encodeFirstFrame || frames.count == 0) {
|
||||||
|
@ -211,15 +211,15 @@ const CFStringRef kCGImagePropertyAPNGUnclampedDelayTime = (__bridge CFStringRef
|
||||||
} else {
|
} else {
|
||||||
// for animated APNG images
|
// for animated APNG images
|
||||||
NSUInteger loopCount = image.sd_imageLoopCount;
|
NSUInteger loopCount = image.sd_imageLoopCount;
|
||||||
NSDictionary *pngProperties = @{(__bridge_transfer NSString *)kCGImagePropertyAPNGLoopCount : @(loopCount)};
|
NSDictionary *pngProperties = @{(__bridge NSString *)kCGImagePropertyAPNGLoopCount : @(loopCount)};
|
||||||
[properties setValue:pngProperties forKey:(__bridge_transfer NSString *)kCGImagePropertyPNGDictionary];
|
[properties setValue:pngProperties forKey:(__bridge NSString *)kCGImagePropertyPNGDictionary];
|
||||||
CGImageDestinationSetProperties(imageDestination, (__bridge CFDictionaryRef)properties);
|
CGImageDestinationSetProperties(imageDestination, (__bridge CFDictionaryRef)properties);
|
||||||
|
|
||||||
for (size_t i = 0; i < frames.count; i++) {
|
for (size_t i = 0; i < frames.count; i++) {
|
||||||
SDImageFrame *frame = frames[i];
|
SDImageFrame *frame = frames[i];
|
||||||
float frameDuration = frame.duration;
|
float frameDuration = frame.duration;
|
||||||
CGImageRef frameImageRef = frame.image.CGImage;
|
CGImageRef frameImageRef = frame.image.CGImage;
|
||||||
NSDictionary *frameProperties = @{(__bridge_transfer NSString *)kCGImagePropertyPNGDictionary : @{(__bridge_transfer NSString *)kCGImagePropertyAPNGDelayTime : @(frameDuration)}};
|
NSDictionary *frameProperties = @{(__bridge NSString *)kCGImagePropertyPNGDictionary : @{(__bridge NSString *)kCGImagePropertyAPNGDelayTime : @(frameDuration)}};
|
||||||
CGImageDestinationAddImage(imageDestination, frameImageRef, (__bridge CFDictionaryRef)frameProperties);
|
CGImageDestinationAddImage(imageDestination, frameImageRef, (__bridge CFDictionaryRef)frameProperties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,7 @@ const CFStringRef kCGImagePropertyAPNGUnclampedDelayTime = (__bridge CFStringRef
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self) {
|
if (self) {
|
||||||
CFStringRef imageUTType = [NSData sd_UTTypeFromSDImageFormat:SDImageFormatPNG];
|
CFStringRef imageUTType = [NSData sd_UTTypeFromSDImageFormat:SDImageFormatPNG];
|
||||||
_imageSource = CGImageSourceCreateIncremental((__bridge CFDictionaryRef)@{(__bridge_transfer NSString *)kCGImageSourceTypeIdentifierHint : (__bridge_transfer NSString *)imageUTType});
|
_imageSource = CGImageSourceCreateIncremental((__bridge CFDictionaryRef)@{(__bridge NSString *)kCGImageSourceTypeIdentifierHint : (__bridge NSString *)imageUTType});
|
||||||
CGFloat scale = 1;
|
CGFloat scale = 1;
|
||||||
if ([options valueForKey:SDImageCoderDecodeScaleFactor]) {
|
if ([options valueForKey:SDImageCoderDecodeScaleFactor]) {
|
||||||
scale = [[options valueForKey:SDImageCoderDecodeScaleFactor] doubleValue];
|
scale = [[options valueForKey:SDImageCoderDecodeScaleFactor] doubleValue];
|
||||||
|
@ -323,7 +323,7 @@ const CFStringRef kCGImagePropertyAPNGUnclampedDelayTime = (__bridge CFStringRef
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self) {
|
if (self) {
|
||||||
// use Image/IO cache because it's already keep a balance between CPU & memory
|
// use Image/IO cache because it's already keep a balance between CPU & memory
|
||||||
CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)data, (__bridge CFDictionaryRef)@{(__bridge_transfer NSString *)kCGImageSourceShouldCache : @(YES)});
|
CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)data, (__bridge CFDictionaryRef)@{(__bridge NSString *)kCGImageSourceShouldCache : @(YES)});
|
||||||
if (!imageSource) {
|
if (!imageSource) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over
|
||||||
SDImageFrame *frame = frames[i];
|
SDImageFrame *frame = frames[i];
|
||||||
float frameDuration = frame.duration;
|
float frameDuration = frame.duration;
|
||||||
CGImageRef frameImageRef = frame.image.CGImage;
|
CGImageRef frameImageRef = frame.image.CGImage;
|
||||||
NSDictionary *frameProperties = @{(__bridge_transfer NSString *)kCGImagePropertyGIFDictionary : @{(__bridge_transfer NSString *)kCGImagePropertyGIFDelayTime : @(frameDuration)}};
|
NSDictionary *frameProperties = @{(__bridge NSString *)kCGImagePropertyGIFDictionary : @{(__bridge NSString *)kCGImagePropertyGIFDelayTime : @(frameDuration)}};
|
||||||
CGImageDestinationAddImage(imageDestination, frameImageRef, (__bridge CFDictionaryRef)frameProperties);
|
CGImageDestinationAddImage(imageDestination, frameImageRef, (__bridge CFDictionaryRef)frameProperties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,9 +132,9 @@
|
||||||
- (NSUInteger)sd_imageLoopCountWithSource:(CGImageSourceRef)source {
|
- (NSUInteger)sd_imageLoopCountWithSource:(CGImageSourceRef)source {
|
||||||
NSUInteger loopCount = 1;
|
NSUInteger loopCount = 1;
|
||||||
NSDictionary *imageProperties = (__bridge_transfer NSDictionary *)CGImageSourceCopyProperties(source, nil);
|
NSDictionary *imageProperties = (__bridge_transfer NSDictionary *)CGImageSourceCopyProperties(source, nil);
|
||||||
NSDictionary *gifProperties = [imageProperties valueForKey:(__bridge_transfer NSString *)kCGImagePropertyGIFDictionary];
|
NSDictionary *gifProperties = [imageProperties valueForKey:(__bridge NSString *)kCGImagePropertyGIFDictionary];
|
||||||
if (gifProperties) {
|
if (gifProperties) {
|
||||||
NSNumber *gifLoopCount = [gifProperties valueForKey:(__bridge_transfer NSString *)kCGImagePropertyGIFLoopCount];
|
NSNumber *gifLoopCount = [gifProperties valueForKey:(__bridge NSString *)kCGImagePropertyGIFLoopCount];
|
||||||
if (gifLoopCount != nil) {
|
if (gifLoopCount != nil) {
|
||||||
loopCount = gifLoopCount.unsignedIntegerValue;
|
loopCount = gifLoopCount.unsignedIntegerValue;
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,7 @@
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self) {
|
if (self) {
|
||||||
CFStringRef imageUTType = [NSData sd_UTTypeFromSDImageFormat:SDImageFormatGIF];
|
CFStringRef imageUTType = [NSData sd_UTTypeFromSDImageFormat:SDImageFormatGIF];
|
||||||
_imageSource = CGImageSourceCreateIncremental((__bridge CFDictionaryRef)@{(__bridge_transfer NSString *)kCGImageSourceTypeIdentifierHint : (__bridge_transfer NSString *)imageUTType});
|
_imageSource = CGImageSourceCreateIncremental((__bridge CFDictionaryRef)@{(__bridge NSString *)kCGImageSourceTypeIdentifierHint : (__bridge NSString *)imageUTType});
|
||||||
CGFloat scale = 1;
|
CGFloat scale = 1;
|
||||||
if ([options valueForKey:SDImageCoderDecodeScaleFactor]) {
|
if ([options valueForKey:SDImageCoderDecodeScaleFactor]) {
|
||||||
scale = [[options valueForKey:SDImageCoderDecodeScaleFactor] doubleValue];
|
scale = [[options valueForKey:SDImageCoderDecodeScaleFactor] doubleValue];
|
||||||
|
@ -284,7 +284,7 @@
|
||||||
if ([options valueForKey:SDImageCoderEncodeCompressionQuality]) {
|
if ([options valueForKey:SDImageCoderEncodeCompressionQuality]) {
|
||||||
compressionQuality = [[options valueForKey:SDImageCoderEncodeCompressionQuality] doubleValue];
|
compressionQuality = [[options valueForKey:SDImageCoderEncodeCompressionQuality] doubleValue];
|
||||||
}
|
}
|
||||||
[properties setValue:@(compressionQuality) forKey:(__bridge_transfer NSString *)kCGImageDestinationLossyCompressionQuality];
|
[properties setValue:@(compressionQuality) forKey:(__bridge NSString *)kCGImageDestinationLossyCompressionQuality];
|
||||||
|
|
||||||
BOOL encodeFirstFrame = [options[SDImageCoderEncodeFirstFrameOnly] boolValue];
|
BOOL encodeFirstFrame = [options[SDImageCoderEncodeFirstFrameOnly] boolValue];
|
||||||
if (encodeFirstFrame || frames.count == 0) {
|
if (encodeFirstFrame || frames.count == 0) {
|
||||||
|
@ -293,15 +293,15 @@
|
||||||
} else {
|
} else {
|
||||||
// for animated GIF images
|
// for animated GIF images
|
||||||
NSUInteger loopCount = image.sd_imageLoopCount;
|
NSUInteger loopCount = image.sd_imageLoopCount;
|
||||||
NSDictionary *gifProperties = @{(__bridge_transfer NSString *)kCGImagePropertyGIFLoopCount : @(loopCount)};
|
NSDictionary *gifProperties = @{(__bridge NSString *)kCGImagePropertyGIFLoopCount : @(loopCount)};
|
||||||
[properties setValue:gifProperties forKey:(__bridge_transfer NSString *)kCGImagePropertyGIFDictionary];
|
[properties setValue:gifProperties forKey:(__bridge NSString *)kCGImagePropertyGIFDictionary];
|
||||||
CGImageDestinationSetProperties(imageDestination, (__bridge CFDictionaryRef)properties);
|
CGImageDestinationSetProperties(imageDestination, (__bridge CFDictionaryRef)properties);
|
||||||
|
|
||||||
for (size_t i = 0; i < frames.count; i++) {
|
for (size_t i = 0; i < frames.count; i++) {
|
||||||
SDImageFrame *frame = frames[i];
|
SDImageFrame *frame = frames[i];
|
||||||
float frameDuration = frame.duration;
|
float frameDuration = frame.duration;
|
||||||
CGImageRef frameImageRef = frame.image.CGImage;
|
CGImageRef frameImageRef = frame.image.CGImage;
|
||||||
NSDictionary *frameProperties = @{(__bridge_transfer NSString *)kCGImagePropertyGIFDictionary : @{(__bridge_transfer NSString *)kCGImagePropertyGIFDelayTime : @(frameDuration)}};
|
NSDictionary *frameProperties = @{(__bridge NSString *)kCGImagePropertyGIFDictionary : @{(__bridge NSString *)kCGImagePropertyGIFDelayTime : @(frameDuration)}};
|
||||||
CGImageDestinationAddImage(imageDestination, frameImageRef, (__bridge CFDictionaryRef)frameProperties);
|
CGImageDestinationAddImage(imageDestination, frameImageRef, (__bridge CFDictionaryRef)frameProperties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self) {
|
if (self) {
|
||||||
// use Image/IO cache because it's already keep a balance between CPU & memory
|
// use Image/IO cache because it's already keep a balance between CPU & memory
|
||||||
CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)data, (__bridge CFDictionaryRef)@{(__bridge_transfer NSString *)kCGImageSourceShouldCache : @(YES)});
|
CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)data, (__bridge CFDictionaryRef)@{(__bridge NSString *)kCGImageSourceShouldCache : @(YES)});
|
||||||
if (!imageSource) {
|
if (!imageSource) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,12 +215,12 @@
|
||||||
#else
|
#else
|
||||||
CGImagePropertyOrientation exifOrientation = kCGImagePropertyOrientationUp;
|
CGImagePropertyOrientation exifOrientation = kCGImagePropertyOrientationUp;
|
||||||
#endif
|
#endif
|
||||||
[properties setValue:@(exifOrientation) forKey:(__bridge_transfer NSString *)kCGImagePropertyOrientation];
|
[properties setValue:@(exifOrientation) forKey:(__bridge NSString *)kCGImagePropertyOrientation];
|
||||||
double compressionQuality = 1;
|
double compressionQuality = 1;
|
||||||
if ([options valueForKey:SDImageCoderEncodeCompressionQuality]) {
|
if ([options valueForKey:SDImageCoderEncodeCompressionQuality]) {
|
||||||
compressionQuality = [[options valueForKey:SDImageCoderEncodeCompressionQuality] doubleValue];
|
compressionQuality = [[options valueForKey:SDImageCoderEncodeCompressionQuality] doubleValue];
|
||||||
}
|
}
|
||||||
[properties setValue:@(compressionQuality) forKey:(__bridge_transfer NSString *)kCGImageDestinationLossyCompressionQuality];
|
[properties setValue:@(compressionQuality) forKey:(__bridge NSString *)kCGImageDestinationLossyCompressionQuality];
|
||||||
|
|
||||||
// Add your image to the destination.
|
// Add your image to the destination.
|
||||||
CGImageDestinationAddImage(imageDestination, image.CGImage, (__bridge CFDictionaryRef)properties);
|
CGImageDestinationAddImage(imageDestination, image.CGImage, (__bridge CFDictionaryRef)properties);
|
||||||
|
|
Loading…
Reference in New Issue