Add a protect when tile rectangle is too small to calculate when using `SDWebImageScaleDownLargeImages`

This commit is contained in:
DreamPiggy 2020-08-10 20:54:04 +08:00
parent b483ec2959
commit a746a3a136
1 changed files with 7 additions and 0 deletions

View File

@ -595,6 +595,7 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over
return NO;
}
CGFloat destTotalPixels;
CGFloat tileTotalPixels;
if (bytes == 0) {
bytes = kDestImageLimitBytes;
}
@ -609,6 +610,12 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over
} else {
shouldScaleDown = NO;
}
// Add a protect when tile rectangle is too small to calculate
// The tile rectangle width equals to image's width, height should be at least 1 pixel
tileTotalPixels = destTotalPixels / 3;
if (tileTotalPixels < sourceResolution.width * 1) {
shouldScaleDown = NO;
}
return shouldScaleDown;
}