From c0cc2456323cfa6ee736b24bf630cf7823962a53 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Tue, 15 Mar 2022 22:35:52 +0800 Subject: [PATCH] Update AppKit SDGraphics convenient API to use main screen colorspace Update macOS demo URL as well --- Examples/SDWebImage OSX Demo/ViewController.m | 2 +- SDWebImage/Core/SDImageGraphics.m | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Examples/SDWebImage OSX Demo/ViewController.m b/Examples/SDWebImage OSX Demo/ViewController.m index 652a61a3..d0175430 100644 --- a/Examples/SDWebImage OSX Demo/ViewController.m +++ b/Examples/SDWebImage OSX Demo/ViewController.m @@ -34,7 +34,7 @@ // NSImageView + Animated Image self.imageView2.sd_imageIndicator = SDWebImageActivityIndicator.largeIndicator; - [self.imageView2 sd_setImageWithURL:[NSURL URLWithString:@"https:raw.githubusercontent.com/onevcat/APNGKit/master/TestImages/APNG-cube.apng"]]; + [self.imageView2 sd_setImageWithURL:[NSURL URLWithString:@"https://raw.githubusercontent.com/onevcat/APNGKit/2.2.0/Tests/APNGKitTests/Resources/General/APNG-cube.apng"]]; NSMenu *menu1 = [[NSMenu alloc] initWithTitle:@"Toggle Animation"]; NSMenuItem *item1 = [menu1 addItemWithTitle:@"Toggle Animation" action:@selector(toggleAnimation:) keyEquivalent:@""]; item1.tag = 1; diff --git a/SDWebImage/Core/SDImageGraphics.m b/SDWebImage/Core/SDImageGraphics.m index f25b0510..358b12e9 100644 --- a/SDWebImage/Core/SDImageGraphics.m +++ b/SDWebImage/Core/SDImageGraphics.m @@ -22,8 +22,7 @@ static CGContextRef SDCGContextCreateBitmapContext(CGSize size, BOOL opaque, CGF size_t height = ceil(size.height * scale); if (width < 1 || height < 1) return NULL; - //pre-multiplied BGRA for non-opaque, BGRX for opaque, 8-bits per component, as Apple's doc - CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB(); + CGColorSpaceRef space = NSScreen.mainScreen.colorSpace.CGColorSpace; // kCGImageAlphaNone is not supported in CGBitmapContextCreate. // Check #3330 for more detail about why this bitmap is choosen. CGBitmapInfo bitmapInfo; @@ -37,7 +36,6 @@ static CGContextRef SDCGContextCreateBitmapContext(CGSize size, BOOL opaque, CGF bitmapInfo = kCGBitmapByteOrderDefault | kCGImageAlphaNoneSkipLast; } CGContextRef context = CGBitmapContextCreate(NULL, width, height, 8, 0, space, bitmapInfo); - CGColorSpaceRelease(space); if (!context) { return NULL; }