Authored by Olivier Poitrey

Merge pull request #379 from lavoy/master

Moved scaling to earlier in the process
... ... @@ -8,6 +8,7 @@
#import "SDWebImageDownloaderOperation.h"
#import "SDWebImageDecoder.h"
#import "UIImage+GIF.h"
#import <ImageIO/ImageIO.h>
@interface SDWebImageDownloaderOperation ()
... ... @@ -274,9 +275,24 @@
}
else
{
UIImage *image = [[UIImage alloc] initWithData:self.imageData];
UIImage *scaledImage = [self scaledImageForKey:self.request.URL.absoluteString image:image];
image = [UIImage decodedImageWithImage:scaledImage];
BOOL isImageGIF = [self.imageData isGIF];
UIImage *image;
if (isImageGIF)
{
image = [UIImage animatedGIFWithData:self.imageData];
}
else
{
image = [[UIImage alloc] initWithData:self.imageData];
}
image = [self scaledImageForKey:self.request.URL.absoluteString image:image];
if (!isImageGIF) {
image = [UIImage decodedImageWithImage:image];
}
if (CGSizeEqualToSize(image.size, CGSizeZero))
{
completionBlock(nil, nil, [NSError errorWithDomain:@"SDWebImageErrorDomain" code:0 userInfo:@{NSLocalizedDescriptionKey: @"Downloaded image has 0 pixels"}], YES);
... ...
... ... @@ -121,13 +121,7 @@
downloaderOptions |= SDWebImageDownloaderIgnoreCachedResponse;
}
__block id<SDWebImageOperation> subOperation = [self.imageDownloader downloadImageWithURL:url options:downloaderOptions progress:progressBlock completed:^(UIImage *downloadedImage, NSData *data, NSError *error, BOOL finished)
{
BOOL isImageGIF = [data isGIF];
if (isImageGIF)
{
downloadedImage = [UIImage animatedGIFWithData:data];
}
{
if (weakOperation.cancelled)
{
completedBlock(nil, nil, SDImageCacheTypeNone, finished);
... ... @@ -155,7 +149,8 @@
else if (downloadedImage && [self.delegate respondsToSelector:@selector(imageManager:transformDownloadedImage:withURL:)])
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^
{
{
BOOL isImageGIF = [data isGIF];
UIImage *transformedImage = isImageGIF ? downloadedImage : [self.delegate imageManager:self transformDownloadedImage:downloadedImage withURL:url];
dispatch_async(dispatch_get_main_queue(), ^
... ...