Merge pull request #3565 from fattiger00/master

Fix bug #3564
This commit is contained in:
DreamPiggy 2023-07-15 15:08:18 +08:00 committed by GitHub
commit 512eb997ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -721,7 +721,7 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over
sourceTileImageRef = CGImageCreateWithImageInRect( sourceImageRef, sourceTile ); sourceTileImageRef = CGImageCreateWithImageInRect( sourceImageRef, sourceTile );
if( y == iterations - 1 && remainder ) { if( y == iterations - 1 && remainder ) {
float dify = destTile.size.height; float dify = destTile.size.height;
destTile.size.height = CGImageGetHeight( sourceTileImageRef ) * imageScale; destTile.size.height = CGImageGetHeight( sourceTileImageRef ) * imageScale + kDestSeemOverlap;
dify -= destTile.size.height; dify -= destTile.size.height;
destTile.origin.y = MIN(0, destTile.origin.y + dify); destTile.origin.y = MIN(0, destTile.origin.y + dify);
} }

View File

@ -96,11 +96,13 @@
expect(decodedImage.size.height).to.equal(1); expect(decodedImage.size.height).to.equal(1);
} }
- (void)test07ThatDecodeAndScaleDownAlwaysCompleteRendering { -(void)test07ThatDecodeAndScaleDownAlwaysCompleteRendering {
// Check that when the height of the image used is not evenly divisible by the height of the tile, the output image can also be rendered completely. // Check that when the height of the image used is not evenly divisible by the height of the tile, the output image can also be rendered completely.
// Check that when the height of the image used will led to loss of precision. the output image can also be rendered completely,
UIColor *imageColor = UIColor.blackColor; UIColor *imageColor = UIColor.blackColor;
CGSize imageSize = CGSizeMake(3024, 4032); CGSize imageSize = CGSizeMake(1029, 1029);
CGRect imageRect = CGRectMake(0, 0, imageSize.width, imageSize.height); CGRect imageRect = CGRectMake(0, 0, imageSize.width, imageSize.height);
SDGraphicsImageRendererFormat *format = [[SDGraphicsImageRendererFormat alloc] init]; SDGraphicsImageRendererFormat *format = [[SDGraphicsImageRendererFormat alloc] init];
format.scale = 1; format.scale = 1;
@ -110,9 +112,11 @@
CGContextFillRect(context, imageRect); CGContextFillRect(context, imageRect);
}]; }];
UIImage *decodedImage = [UIImage sd_decodedAndScaledDownImageWithImage:image limitBytes:20 * 1024 * 1024]; UIImage *decodedImage = [UIImage sd_decodedAndScaledDownImageWithImage:image limitBytes:1 * 1024 * 1024];
UIColor *testColor = [decodedImage sd_colorAtPoint:CGPointMake(0, decodedImage.size.height - 1)]; UIColor *testColor1 = [decodedImage sd_colorAtPoint:CGPointMake(0, decodedImage.size.height - 1)];
expect(testColor.sd_hexString).equal(imageColor.sd_hexString); UIColor *testColor2 = [decodedImage sd_colorAtPoint:CGPointMake(0, decodedImage.size.height - 9)];
expect(testColor1.sd_hexString).equal(imageColor.sd_hexString);
expect(testColor2.sd_hexString).equal(imageColor.sd_hexString);
} }
- (void)test08ThatEncodeAlphaImageToJPGWithBackgroundColor { - (void)test08ThatEncodeAlphaImageToJPGWithBackgroundColor {