For ImageIO coder, if the image is scaled down, then we need to modify the original image data pointer

This commit is contained in:
DreamPiggy 2017-10-24 02:48:50 +08:00
parent cd37ef672b
commit d62e965833
1 changed files with 10 additions and 1 deletions

View File

@ -213,7 +213,16 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over
if (!shouldScaleDown) {
return [self sd_decompressedImageWithImage:image];
} else {
return [self sd_decompressedAndScaledDownImageWithImage:image];
UIImage *scaledDownImage = [self sd_decompressedAndScaledDownImageWithImage:image];
if (scaledDownImage && !CGSizeEqualToSize(scaledDownImage.size, image.size)) {
// if the image is scaled down, need to modify the data pointer as well
SDImageFormat format = [NSData sd_imageFormatForImageData:*data];
NSData *imageData = [self encodedDataWithImage:scaledDownImage format:format];
if (imageData) {
*data = imageData;
}
}
return scaledDownImage;
}
#endif
}