Unify the colorspace on macOS/watchOS choosen for draw to use sRGB firstly

Remove the unused OS version check
This commit is contained in:
DreamPiggy 2022-03-16 14:56:34 +08:00
parent 368825eff6
commit 874b674cb6
2 changed files with 3 additions and 16 deletions

View File

@ -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;
}

View File

@ -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;