Merge pull request #194 from NachoSoto/patch-1

Keeping original image alpha info when decoding
This commit is contained in:
Olivier Poitrey 2012-10-10 16:38:26 -07:00
commit 6818520744
1 changed files with 2 additions and 4 deletions

View File

@ -98,6 +98,7 @@ static SDWebImageDecoder *sharedInstance;
{
CGImageRef imageRef = image.CGImage;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGImageAlphaInfo alphaInfo = CGImageGetAlphaInfo(imageRef);
CGContextRef context = CGBitmapContextCreate(NULL,
CGImageGetWidth(imageRef),
CGImageGetHeight(imageRef),
@ -107,10 +108,7 @@ static SDWebImageDecoder *sharedInstance;
// System only supports RGB, set explicitly
colorSpace,
// Makes system don't need to do extra conversion when displayed.
// NOTE: here we remove the alpha channel for performance. Most of the time, images loaded
// from the network are jpeg with no alpha channel. As a TODO, finding a way to detect
// if alpha channel is necessary would be nice.
kCGImageAlphaNoneSkipLast | kCGBitmapByteOrder32Little);
alphaInfo | kCGBitmapByteOrder32Little);
CGColorSpaceRelease(colorSpace);
if (!context) return nil;