Add test case for CGImage create decoded with EXIF orientation
This commit is contained in:
parent
4dce559d44
commit
9c6c4927fb
|
@ -14,6 +14,8 @@
|
|||
3226ECBC20754F7700FAFACF /* SDWebImageTestDownloadOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 3226ECBA20754F7700FAFACF /* SDWebImageTestDownloadOperation.m */; };
|
||||
323B8E1F20862322008952BE /* SDWebImageTestLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 323B8E1E20862322008952BE /* SDWebImageTestLoader.m */; };
|
||||
323B8E2020862322008952BE /* SDWebImageTestLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 323B8E1E20862322008952BE /* SDWebImageTestLoader.m */; };
|
||||
324047442271956F007C53E1 /* TestEXIF.png in Resources */ = {isa = PBXBuildFile; fileRef = 324047432271956F007C53E1 /* TestEXIF.png */; };
|
||||
324047452271956F007C53E1 /* TestEXIF.png in Resources */ = {isa = PBXBuildFile; fileRef = 324047432271956F007C53E1 /* TestEXIF.png */; };
|
||||
3254C32020641077008D1022 /* SDImageTransformerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3254C31F20641077008D1022 /* SDImageTransformerTests.m */; };
|
||||
3254C32120641077008D1022 /* SDImageTransformerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3254C31F20641077008D1022 /* SDImageTransformerTests.m */; };
|
||||
3264FF2F205D42CB00F6BD48 /* SDWebImageTestTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 3264FF2E205D42CB00F6BD48 /* SDWebImageTestTransformer.m */; };
|
||||
|
@ -79,6 +81,7 @@
|
|||
3226ECBA20754F7700FAFACF /* SDWebImageTestDownloadOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDWebImageTestDownloadOperation.m; sourceTree = "<group>"; };
|
||||
323B8E1D20862322008952BE /* SDWebImageTestLoader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDWebImageTestLoader.h; sourceTree = "<group>"; };
|
||||
323B8E1E20862322008952BE /* SDWebImageTestLoader.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDWebImageTestLoader.m; sourceTree = "<group>"; };
|
||||
324047432271956F007C53E1 /* TestEXIF.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = TestEXIF.png; sourceTree = "<group>"; };
|
||||
3254C31F20641077008D1022 /* SDImageTransformerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDImageTransformerTests.m; sourceTree = "<group>"; };
|
||||
3264FF2D205D42CB00F6BD48 /* SDWebImageTestTransformer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDWebImageTestTransformer.h; sourceTree = "<group>"; };
|
||||
3264FF2E205D42CB00F6BD48 /* SDWebImageTestTransformer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDWebImageTestTransformer.m; sourceTree = "<group>"; };
|
||||
|
@ -170,6 +173,7 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
433BBBBA1D7EFA8B0086B6E9 /* MonochromeTestImage.jpg */,
|
||||
324047432271956F007C53E1 /* TestEXIF.png */,
|
||||
433BBBB61D7EF8200086B6E9 /* TestImage.gif */,
|
||||
5F7F38AC1AE2A77A00B0E330 /* TestImage.jpg */,
|
||||
43828A441DA67F9900000E62 /* TestImageLarge.jpg */,
|
||||
|
@ -352,6 +356,7 @@
|
|||
327054E3206CEFF3006EA328 /* TestImageAnimated.apng in Resources */,
|
||||
32B99EA3203B31360017FD66 /* TestImage.gif in Resources */,
|
||||
328BAF2C2240C08E00FC70DD /* Test-Release.xcconfig in Resources */,
|
||||
324047452271956F007C53E1 /* TestEXIF.png in Resources */,
|
||||
328BAF2E2240C08E00FC70DD /* Test-Debug.xcconfig in Resources */,
|
||||
32B99EA4203B31360017FD66 /* TestImage.jpg in Resources */,
|
||||
32B99EA6203B31360017FD66 /* TestImage.png in Resources */,
|
||||
|
@ -379,6 +384,7 @@
|
|||
433BBBB91D7EF8260086B6E9 /* TestImage.png in Resources */,
|
||||
327054E2206CEFF3006EA328 /* TestImageAnimated.apng in Resources */,
|
||||
433BBBBB1D7EFA8B0086B6E9 /* MonochromeTestImage.jpg in Resources */,
|
||||
324047442271956F007C53E1 /* TestEXIF.png in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
|
@ -208,18 +208,65 @@
|
|||
expect(SDTransformedKeyForKey(key, transformerKey)).equal(@"ftp://root:password@foo.com/image-SDImageFlippingTransformer(1,0).png");
|
||||
}
|
||||
|
||||
- (void)test20CGImageCreateDecodedWithOrientation {
|
||||
// Test EXIF orientation tag, you can open this image with `Preview.app`, open inspector (Command+I) and rotate (Command+L/R) to check
|
||||
UIImage *image = [[UIImage alloc] initWithContentsOfFile:[self testPNGPathForName:@"TestEXIF"]];
|
||||
CGImageRef originalCGImage = image.CGImage;
|
||||
expect(image).notTo.beNil();
|
||||
|
||||
CGImageRef upCGImage = [SDImageCoderHelper CGImageCreateDecoded:originalCGImage orientation:kCGImagePropertyOrientationUp];
|
||||
UIImage *upImage = [[UIImage alloc] initWithCGImage:upCGImage];
|
||||
expect([[upImage sd_colorAtPoint:CGPointMake(60, 160)].sd_hexString isEqualToString:UIColor.blackColor.sd_hexString]).beTruthy();
|
||||
CGImageRelease(upCGImage);
|
||||
|
||||
CGImageRef upMirroredCGImage = [SDImageCoderHelper CGImageCreateDecoded:originalCGImage orientation:kCGImagePropertyOrientationUpMirrored];
|
||||
UIImage *upMirroredImage = [[UIImage alloc] initWithCGImage:upMirroredCGImage];
|
||||
expect([[upMirroredImage sd_colorAtPoint:CGPointMake(130, 160)].sd_hexString isEqualToString:UIColor.blackColor.sd_hexString]).beTruthy();
|
||||
CGImageRelease(upMirroredCGImage);
|
||||
|
||||
CGImageRef downCGImage = [SDImageCoderHelper CGImageCreateDecoded:originalCGImage orientation:kCGImagePropertyOrientationDown];
|
||||
UIImage *downImage = [[UIImage alloc] initWithCGImage:downCGImage];
|
||||
expect([[downImage sd_colorAtPoint:CGPointMake(130, 30)].sd_hexString isEqualToString:UIColor.blackColor.sd_hexString]).beTruthy();
|
||||
CGImageRelease(downCGImage);
|
||||
|
||||
CGImageRef downMirrorerdCGImage = [SDImageCoderHelper CGImageCreateDecoded:originalCGImage orientation:kCGImagePropertyOrientationDownMirrored];
|
||||
UIImage *downMirroredImage = [[UIImage alloc] initWithCGImage:downMirrorerdCGImage];
|
||||
expect([[downMirroredImage sd_colorAtPoint:CGPointMake(60, 30)].sd_hexString isEqualToString:UIColor.blackColor.sd_hexString]).beTruthy();
|
||||
CGImageRelease(downMirrorerdCGImage);
|
||||
|
||||
CGImageRef leftMirroredCGImage = [SDImageCoderHelper CGImageCreateDecoded:originalCGImage orientation:kCGImagePropertyOrientationLeftMirrored];
|
||||
UIImage *leftMirroredImage = [[UIImage alloc] initWithCGImage:leftMirroredCGImage];
|
||||
expect([[leftMirroredImage sd_colorAtPoint:CGPointMake(160, 60)].sd_hexString isEqualToString:UIColor.blackColor.sd_hexString]).beTruthy();
|
||||
CGImageRelease(leftMirroredCGImage);
|
||||
|
||||
CGImageRef rightCGImage = [SDImageCoderHelper CGImageCreateDecoded:originalCGImage orientation:kCGImagePropertyOrientationRight];
|
||||
UIImage *rightImage = [[UIImage alloc] initWithCGImage:rightCGImage];
|
||||
expect([[rightImage sd_colorAtPoint:CGPointMake(30, 60)].sd_hexString isEqualToString:UIColor.blackColor.sd_hexString]).beTruthy();
|
||||
CGImageRelease(rightCGImage);
|
||||
|
||||
CGImageRef rightMirroredCGImage = [SDImageCoderHelper CGImageCreateDecoded:originalCGImage orientation:kCGImagePropertyOrientationRightMirrored];
|
||||
UIImage *rightMirroredImage = [[UIImage alloc] initWithCGImage:rightMirroredCGImage];
|
||||
expect([[rightMirroredImage sd_colorAtPoint:CGPointMake(30, 130)].sd_hexString isEqualToString:UIColor.blackColor.sd_hexString]).beTruthy();
|
||||
CGImageRelease(rightMirroredCGImage);
|
||||
|
||||
CGImageRef leftCGImage = [SDImageCoderHelper CGImageCreateDecoded:originalCGImage orientation:kCGImagePropertyOrientationLeft];
|
||||
UIImage *leftImage = [[UIImage alloc] initWithCGImage:leftCGImage];
|
||||
expect([[leftImage sd_colorAtPoint:CGPointMake(160, 130)].sd_hexString isEqualToString:UIColor.blackColor.sd_hexString]).beTruthy();
|
||||
CGImageRelease(leftCGImage);
|
||||
}
|
||||
|
||||
#pragma mark - Helper
|
||||
|
||||
- (UIImage *)testImage {
|
||||
if (!_testImage) {
|
||||
_testImage = [[UIImage alloc] initWithContentsOfFile:[self testPNGPath]];
|
||||
_testImage = [[UIImage alloc] initWithContentsOfFile:[self testPNGPathForName:@"TestImage"]];
|
||||
}
|
||||
return _testImage;
|
||||
}
|
||||
|
||||
- (NSString *)testPNGPath {
|
||||
- (NSString *)testPNGPathForName:(NSString *)name {
|
||||
NSBundle *testBundle = [NSBundle bundleForClass:[self class]];
|
||||
return [testBundle pathForResource:@"TestImage" ofType:@"png"];
|
||||
return [testBundle pathForResource:name ofType:@"png"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue