diff --git a/SDWebImage/Core/SDImageCoderHelper.m b/SDWebImage/Core/SDImageCoderHelper.m index fc276622..1f641212 100644 --- a/SDWebImage/Core/SDImageCoderHelper.m +++ b/SDWebImage/Core/SDImageCoderHelper.m @@ -189,24 +189,10 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over } + (CGColorSpaceRef)colorSpaceGetDeviceRGB { -#if SD_MAC - CGColorSpaceRef screenColorSpace = NSScreen.mainScreen.colorSpace.CGColorSpace; - if (screenColorSpace) { - return screenColorSpace; - } -#endif static CGColorSpaceRef colorSpace; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ -#if SD_UIKIT - if (@available(iOS 9.0, tvOS 9.0, *)) { - colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB); - } else { - colorSpace = CGColorSpaceCreateDeviceRGB(); - } -#else - colorSpace = CGColorSpaceCreateDeviceRGB(); -#endif + colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB); }); return colorSpace; } diff --git a/SDWebImage/Core/SDImageGraphics.m b/SDWebImage/Core/SDImageGraphics.m index 358b12e9..f6f89279 100644 --- a/SDWebImage/Core/SDImageGraphics.m +++ b/SDWebImage/Core/SDImageGraphics.m @@ -8,6 +8,7 @@ #import "SDImageGraphics.h" #import "NSImage+Compatibility.h" +#import "SDImageCoderHelper.h" #import "objc/runtime.h" #if SD_MAC @@ -22,7 +23,7 @@ static CGContextRef SDCGContextCreateBitmapContext(CGSize size, BOOL opaque, CGF size_t height = ceil(size.height * scale); if (width < 1 || height < 1) return NULL; - CGColorSpaceRef space = NSScreen.mainScreen.colorSpace.CGColorSpace; + CGColorSpaceRef space = [SDImageCoderHelper colorSpaceGetDeviceRGB]; // kCGImageAlphaNone is not supported in CGBitmapContextCreate. // Check #3330 for more detail about why this bitmap is choosen. CGBitmapInfo bitmapInfo;