Merge pull request #379 from lavoy/master
Moved scaling to earlier in the process
This commit is contained in:
commit
65807f262e
|
@ -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);
|
||||||
|
|
|
@ -121,13 +121,7 @@
|
||||||
downloaderOptions |= SDWebImageDownloaderIgnoreCachedResponse;
|
downloaderOptions |= SDWebImageDownloaderIgnoreCachedResponse;
|
||||||
}
|
}
|
||||||
__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);
|
||||||
|
@ -155,7 +149,8 @@
|
||||||
else if (downloadedImage && [self.delegate respondsToSelector:@selector(imageManager:transformDownloadedImage:withURL:)])
|
else if (downloadedImage && [self.delegate respondsToSelector:@selector(imageManager:transformDownloadedImage:withURL:)])
|
||||||
{
|
{
|
||||||
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(), ^
|
||||||
|
|
Loading…
Reference in New Issue