From 6dcbec2b87487df99946c329f7283e1a8d0b61fb Mon Sep 17 00:00:00 2001 From: lizhuoli Date: Thu, 3 Mar 2022 22:06:04 +0800 Subject: [PATCH] Update the test case and use Xcode 13.2.1 with iOS 15.3+ simulator --- .github/workflows/CI.yml | 8 ++++---- SDWebImage/Core/SDImageCoderHelper.m | 6 +++--- Tests/Tests/SDImageTransformerTests.m | 10 ++++++++++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8dcc0e7a..815b186d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -13,7 +13,7 @@ jobs: name: Cocoapods Lint runs-on: macos-11 env: - DEVELOPER_DIR: /Applications/Xcode_13.0.app + DEVELOPER_DIR: /Applications/Xcode_13.2.1.app steps: - name: Checkout uses: actions/checkout@v2 @@ -39,7 +39,7 @@ jobs: name: Run Demo runs-on: macos-11 env: - DEVELOPER_DIR: /Applications/Xcode_13.0.app + DEVELOPER_DIR: /Applications/Xcode_13.2.1.app WORKSPACE_NAME: SDWebImage.xcworkspace OSXSCHEME: SDWebImage OSX Demo iOSSCHEME: SDWebImage iOS Demo @@ -92,7 +92,7 @@ jobs: name: Unit Test runs-on: macos-11 env: - DEVELOPER_DIR: /Applications/Xcode_13.0.app + DEVELOPER_DIR: /Applications/Xcode_13.2.1.app WORKSPACE_NAME: SDWebImage.xcworkspace strategy: matrix: @@ -151,7 +151,7 @@ jobs: name: Build Library runs-on: macos-11 env: - DEVELOPER_DIR: /Applications/Xcode_13.0.app + DEVELOPER_DIR: /Applications/Xcode_13.2.1.app PROJECT_NAME: SDWebImage.xcodeproj SCHEME_NAME: SDWebImage steps: diff --git a/SDWebImage/Core/SDImageCoderHelper.m b/SDWebImage/Core/SDImageCoderHelper.m index 030cf8c1..eb5116ba 100644 --- a/SDWebImage/Core/SDImageCoderHelper.m +++ b/SDWebImage/Core/SDImageCoderHelper.m @@ -259,7 +259,7 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over CGContextRef context = NULL; if (@available(iOS 15, tvOS 15, macOS 12, watchOS 8, *)) { // Update for iOS 15: CoreGraphics's draw image will fail to transcode and draw some special CGImage on BGRX8888 - // We prefer to use the input CGImaage's bitmap firstly, then fallback to BGRA. See #3330 + // We prefer to use the input CGImage's bitmap firstly, then fallback to BGRAX8888. See #3330 bitmapInfo = CGImageGetBitmapInfo(cgImage); context = CGBitmapContextCreate(NULL, newWidth, newHeight, 8, 0, [self colorSpaceGetDeviceRGB], bitmapInfo); } @@ -396,8 +396,8 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over // to create bitmap graphics contexts without alpha info. CGBitmapInfo bitmapInfo; if (@available(iOS 15, tvOS 15, macOS 12, watchOS 8, *)) { - // Update for iOS 15: CoreGraphics's draw image will fail to transcode and draw some special CGImage on BGRX8888 - // We prefer to use the input CGImaage's bitmap firstly, then fallback to BGRA. See #3330 + // Update for iOS 15: CoreGraphics's draw image will fail to transcode some special CGImage on BGRX8888 + // We prefer to use the input CGImage's bitmap firstly, then fallback to BGRAX8888. See #3330 bitmapInfo = CGImageGetBitmapInfo(sourceImageRef); destContext = CGBitmapContextCreate(NULL, destResolution.width, diff --git a/Tests/Tests/SDImageTransformerTests.m b/Tests/Tests/SDImageTransformerTests.m index 03b7a59a..811268f0 100644 --- a/Tests/Tests/SDImageTransformerTests.m +++ b/Tests/Tests/SDImageTransformerTests.m @@ -406,6 +406,16 @@ CGImageRelease(leftCGImage); } +- (void)test21BMPImageCreateDecodedShouldNotBlank { + UIImage *testImage = [[UIImage alloc] initWithContentsOfFile:[self testBMPPathForName:@"TestImage"]]; + CGImageRef cgImage = testImage.CGImage; + expect(cgImage).notTo.beNil(); + UIImage *decodedImage = [SDImageCoderHelper decodedImageWithImage:testImage]; + expect(decodedImage).notTo.beNil(); + UIColor *testColor = [decodedImage sd_colorAtPoint:CGPointMake(100, 100)]; + expect([[testColor sd_hexString] isEqualToString:@"#ff0a64bf"]).beTruthy(); +} + #pragma mark - Helper - (UIImage *)testImageCG {