Merge pull request #1496 from yamasakitomohiro/master
fixes CGContextDrawImage: invalid context 0x0 https://github.com/rs/SDWebImage/issues/1401 https://github.com/rs/SDWebImage/issues/1454 https://github.com/rs/SDWebImage/issues/1457
This commit is contained in:
commit
1ef791bad9
|
@ -33,9 +33,6 @@
|
|||
|
||||
if (anyAlpha) { return image; }
|
||||
|
||||
size_t width = CGImageGetWidth(imageRef);
|
||||
size_t height = CGImageGetHeight(imageRef);
|
||||
|
||||
// current
|
||||
CGColorSpaceModel imageColorSpaceModel = CGColorSpaceGetModel(CGImageGetColorSpace(imageRef));
|
||||
CGColorSpaceRef colorspaceRef = CGImageGetColorSpace(imageRef);
|
||||
|
@ -44,10 +41,17 @@
|
|||
if (unsupportedColorSpace)
|
||||
colorspaceRef = CGColorSpaceCreateDeviceRGB();
|
||||
|
||||
CGContextRef context = CGBitmapContextCreate(NULL, width,
|
||||
size_t width = CGImageGetWidth(imageRef);
|
||||
size_t height = CGImageGetHeight(imageRef);
|
||||
NSUInteger bytesPerPixel = 4;
|
||||
NSUInteger bytesPerRow = bytesPerPixel * width;
|
||||
NSUInteger bitsPerComponent = 8;
|
||||
|
||||
CGContextRef context = CGBitmapContextCreate(NULL,
|
||||
width,
|
||||
height,
|
||||
CGImageGetBitsPerComponent(imageRef),
|
||||
0,
|
||||
bitsPerComponent,
|
||||
bytesPerRow,
|
||||
colorspaceRef,
|
||||
kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedFirst);
|
||||
|
||||
|
|
Loading…
Reference in New Issue