From 1bf9668d975279d808959b804307a2ffba268d24 Mon Sep 17 00:00:00 2001 From: Nacho Soto Date: Wed, 10 Oct 2012 16:36:53 -0700 Subject: [PATCH] Keeping original image alpha info when decoding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes issue #26 and #55, after the change introduced in commit c32f9c03f816dac58a8cac25d6189310272ca9c1 --- SDWebImage/SDWebImageDecoder.m | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/SDWebImage/SDWebImageDecoder.m b/SDWebImage/SDWebImageDecoder.m index 9b6e50c..34af4e4 100644 --- a/SDWebImage/SDWebImageDecoder.m +++ b/SDWebImage/SDWebImageDecoder.m @@ -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;