For ImageIO coder, if the image is scaled down, then we need to modify the origi…
…nal image data pointer
Showing
1 changed file
with
10 additions
and
1 deletions
@@ -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 | } |
-
Please register or login to post a comment