Fixed Alpha chanel detection when decoding images.

This commit is contained in:
Jure Žove 2012-10-28 19:58:14 +01:00 committed by Olivier Poitrey
parent 1a360b6faf
commit c609027314
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;