From a34133b86465b10578dc37747b02735ab61977f2 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Mon, 21 May 2018 14:56:55 +0800 Subject: [PATCH] Fix the progressive decoding bug on macOS. Including image orientation & SDAnimatedimageView --- SDWebImage/NSImage+Compatibility.m | 2 +- SDWebImage/SDAnimatedImageView.m | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/SDWebImage/NSImage+Compatibility.m b/SDWebImage/NSImage+Compatibility.m index 9672fa11..b42a2e09 100644 --- a/SDWebImage/NSImage+Compatibility.m +++ b/SDWebImage/NSImage+Compatibility.m @@ -46,7 +46,7 @@ // AppKit design is different from UIKit. Where CGImage based image rep does not respect to any orientation. Only data based image rep which contains the EXIF metadata can automatically detect orientation. // This should be nonnull, until the memory is exhausted cause `CGBitmapContextCreate` failed. CGImageRef rotatedCGImage = [SDImageCoderHelper CGImageCreateDecoded:cgImage orientation:orientation]; - imageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage]; + imageRep = [[NSBitmapImageRep alloc] initWithCGImage:rotatedCGImage]; CGImageRelease(rotatedCGImage); } else { imageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage]; diff --git a/SDWebImage/SDAnimatedImageView.m b/SDWebImage/SDAnimatedImageView.m index af4a4e6c..0bf6bdc4 100644 --- a/SDWebImage/SDAnimatedImageView.m +++ b/SDWebImage/SDAnimatedImageView.m @@ -322,6 +322,9 @@ dispatch_semaphore_signal(self->_lock); } [self.layer setNeedsDisplay]; +#if SD_MAC + [self.layer displayIfNeeded]; // macOS's imageViewLayer is not equal to self.layer. But `[super setImage:]` will impliedly mark it needsDisplay. We call `[self.layer displayIfNeeded]` to immediately refresh the imageViewLayer to avoid flashing +#endif } }