moved scaling up the process

This commit is contained in:
Andy LaVoy 2013-04-28 20:10:36 -07:00
parent ad4babd25d
commit f58c2ebb43
2 changed files with 22 additions and 11 deletions

View File

@ -8,6 +8,7 @@
#import "SDWebImageDownloaderOperation.h" #import "SDWebImageDownloaderOperation.h"
#import "SDWebImageDecoder.h" #import "SDWebImageDecoder.h"
#import "UIImage+GIF.h"
#import <ImageIO/ImageIO.h> #import <ImageIO/ImageIO.h>
@interface SDWebImageDownloaderOperation () @interface SDWebImageDownloaderOperation ()
@ -274,9 +275,24 @@
} }
else else
{ {
UIImage *image = [[UIImage alloc] initWithData:self.imageData]; BOOL isImageGIF = [self.imageData isGIF];
UIImage *scaledImage = [self scaledImageForKey:self.request.URL.absoluteString image:image];
image = [UIImage decodedImageWithImage:scaledImage]; 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)) if (CGSizeEqualToSize(image.size, CGSizeZero))
{ {
completionBlock(nil, nil, [NSError errorWithDomain:@"SDWebImageErrorDomain" code:0 userInfo:@{NSLocalizedDescriptionKey: @"Downloaded image has 0 pixels"}], YES); completionBlock(nil, nil, [NSError errorWithDomain:@"SDWebImageErrorDomain" code:0 userInfo:@{NSLocalizedDescriptionKey: @"Downloaded image has 0 pixels"}], YES);

View File

@ -122,12 +122,6 @@
} }
__block id<SDWebImageOperation> subOperation = [self.imageDownloader downloadImageWithURL:url options:downloaderOptions progress:progressBlock completed:^(UIImage *downloadedImage, NSData *data, NSError *error, BOOL finished) __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) if (weakOperation.cancelled)
{ {
completedBlock(nil, nil, SDImageCacheTypeNone, finished); completedBlock(nil, nil, SDImageCacheTypeNone, finished);
@ -156,6 +150,7 @@
{ {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^ 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]; UIImage *transformedImage = isImageGIF ? downloadedImage : [self.delegate imageManager:self transformDownloadedImage:downloadedImage withURL:url];
dispatch_async(dispatch_get_main_queue(), ^ dispatch_async(dispatch_get_main_queue(), ^