Authored by Bogdan Poplauschi
Committed by GitHub

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
@@ -213,7 +213,16 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over @@ -213,7 +213,16 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over
213 if (!shouldScaleDown) { 213 if (!shouldScaleDown) {
214 return [self sd_decompressedImageWithImage:image]; 214 return [self sd_decompressedImageWithImage:image];
215 } else { 215 } else {
216 - return [self sd_decompressedAndScaledDownImageWithImage:image]; 216 + UIImage *scaledDownImage = [self sd_decompressedAndScaledDownImageWithImage:image];
  217 + if (scaledDownImage && !CGSizeEqualToSize(scaledDownImage.size, image.size)) {
  218 + // if the image is scaled down, need to modify the data pointer as well
  219 + SDImageFormat format = [NSData sd_imageFormatForImageData:*data];
  220 + NSData *imageData = [self encodedDataWithImage:scaledDownImage format:format];
  221 + if (imageData) {
  222 + *data = imageData;
  223 + }
  224 + }
  225 + return scaledDownImage;
217 } 226 }
218 #endif 227 #endif
219 } 228 }