Merge pull request #2074 from dreampiggy/fix_scale_down_and_set_data

For ImageIO coder, if the image is scaled down, then we need to modify the original image data pointer
This commit is contained in:
Bogdan Poplauschi 2017-10-24 09:22:27 +03:00 committed by GitHub
commit 6bab618acc
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
}