Update AppKit SDGraphics convenient API to use main screen colorspace

Update macOS demo URL as well
This commit is contained in:
DreamPiggy 2022-03-15 22:35:52 +08:00
parent fce270631f
commit c0cc245632
2 changed files with 2 additions and 4 deletions

View File

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

View File

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