Update AppKit SDGraphics convenient API to use main screen colorspace
Update macOS demo URL as well
This commit is contained in:
parent
fce270631f
commit
c0cc245632
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
// NSImageView + Animated Image
|
// NSImageView + Animated Image
|
||||||
self.imageView2.sd_imageIndicator = SDWebImageActivityIndicator.largeIndicator;
|
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"];
|
NSMenu *menu1 = [[NSMenu alloc] initWithTitle:@"Toggle Animation"];
|
||||||
NSMenuItem *item1 = [menu1 addItemWithTitle:@"Toggle Animation" action:@selector(toggleAnimation:) keyEquivalent:@""];
|
NSMenuItem *item1 = [menu1 addItemWithTitle:@"Toggle Animation" action:@selector(toggleAnimation:) keyEquivalent:@""];
|
||||||
item1.tag = 1;
|
item1.tag = 1;
|
||||||
|
|
|
@ -22,8 +22,7 @@ static CGContextRef SDCGContextCreateBitmapContext(CGSize size, BOOL opaque, CGF
|
||||||
size_t height = ceil(size.height * scale);
|
size_t height = ceil(size.height * scale);
|
||||||
if (width < 1 || height < 1) return NULL;
|
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 = NSScreen.mainScreen.colorSpace.CGColorSpace;
|
||||||
CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
|
|
||||||
// kCGImageAlphaNone is not supported in CGBitmapContextCreate.
|
// kCGImageAlphaNone is not supported in CGBitmapContextCreate.
|
||||||
// Check #3330 for more detail about why this bitmap is choosen.
|
// Check #3330 for more detail about why this bitmap is choosen.
|
||||||
CGBitmapInfo bitmapInfo;
|
CGBitmapInfo bitmapInfo;
|
||||||
|
@ -37,7 +36,6 @@ static CGContextRef SDCGContextCreateBitmapContext(CGSize size, BOOL opaque, CGF
|
||||||
bitmapInfo = kCGBitmapByteOrderDefault | kCGImageAlphaNoneSkipLast;
|
bitmapInfo = kCGBitmapByteOrderDefault | kCGImageAlphaNoneSkipLast;
|
||||||
}
|
}
|
||||||
CGContextRef context = CGBitmapContextCreate(NULL, width, height, 8, 0, space, bitmapInfo);
|
CGContextRef context = CGBitmapContextCreate(NULL, width, height, 8, 0, space, bitmapInfo);
|
||||||
CGColorSpaceRelease(space);
|
|
||||||
if (!context) {
|
if (!context) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue