Add test case: test07ThatDecodeAndScaleDownAlwaysCompleteRendering
This commit is contained in:
parent
8ce13403bc
commit
33ff352d4e
|
@ -96,6 +96,25 @@
|
|||
expect(decodedImage.size.height).to.equal(1);
|
||||
}
|
||||
|
||||
- (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.
|
||||
|
||||
UIColor *imageColor = UIColor.blackColor;
|
||||
CGSize imageSize = CGSizeMake(3024, 4032);
|
||||
CGRect imageRect = CGRectMake(0, 0, imageSize.width, imageSize.height);
|
||||
SDGraphicsImageRendererFormat *format = [[SDGraphicsImageRendererFormat alloc] init];
|
||||
format.scale = 1;
|
||||
SDGraphicsImageRenderer *renderer = [[SDGraphicsImageRenderer alloc] initWithSize:imageSize format:format];
|
||||
UIImage *image = [renderer imageWithActions:^(CGContextRef _Nonnull context) {
|
||||
CGContextSetFillColorWithColor(context, [imageColor CGColor]);
|
||||
CGContextFillRect(context, imageRect);
|
||||
}];
|
||||
|
||||
UIImage *decodedImage = [UIImage sd_decodedAndScaledDownImageWithImage:image limitBytes:20 * 1024 * 1024];
|
||||
UIColor *testColor = [decodedImage sd_colorAtPoint:CGPointMake(0, decodedImage.size.height - 1)];
|
||||
expect(testColor.sd_hexString).equal(imageColor.sd_hexString);
|
||||
}
|
||||
|
||||
- (void)test08ThatEncodeAlphaImageToJPGWithBackgroundColor {
|
||||
NSString *testImagePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestImage" ofType:@"png"];
|
||||
UIImage *image = [[UIImage alloc] initWithContentsOfFile:testImagePath];
|
||||
|
|
Loading…
Reference in New Issue