Fixed Alpha chanel detection when decoding images.

This commit is contained in:
Jure Žove 2012-10-28 19:58:14 +01:00
parent ab07f23fbc
commit e6ede1104c
1 changed files with 3 additions and 1 deletions

View File

@ -100,7 +100,9 @@ static SDWebImageDecoder *sharedInstance;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGImageAlphaInfo alphaInfo = CGImageGetAlphaInfo(imageRef);
BOOL imageHasAlphaInfo = (alphaInfo != kCGImageAlphaNone);
BOOL imageHasAlphaInfo = (alphaInfo != kCGImageAlphaNone &&
alphaInfo != kCGImageAlphaNoneSkipFirst &&
alphaInfo != kCGImageAlphaNoneSkipLast);
int bytesPerPixel = imageHasAlphaInfo ? 4 : 3;
CGBitmapInfo bitmapInfo = imageHasAlphaInfo ? kCGImageAlphaPremultipliedLast : kCGImageAlphaNone;