From c18c2c8757a4179e5f1884425a3108dbee186105 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Tue, 14 May 2019 20:50:17 +0800 Subject: [PATCH] Fix the logic for Animated WebP images which contains a subsequence blend from the first frame, impact the `SDAnimatedImage` --- SDWebImageWebPCoder/Classes/SDImageWebPCoder.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m b/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m index b1fb2fc..7a11965 100644 --- a/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m +++ b/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m @@ -46,8 +46,8 @@ @property (nonatomic, assign) NSUInteger offsetY; // Frame origin.y in canvas (left-bottom based) @property (nonatomic, assign) BOOL hasAlpha; // Whether frame contains alpha @property (nonatomic, assign) BOOL isFullSize; // Whether frame size is equal to canvas size -@property (nonatomic, assign) WebPMuxAnimBlend blend; // Frame dispose method -@property (nonatomic, assign) WebPMuxAnimDispose dispose; // Frame blend operation +@property (nonatomic, assign) BOOL shouldBlend; // Frame dispose method +@property (nonatomic, assign) BOOL shouldDispose; // Frame blend operation @property (nonatomic, assign) NSUInteger blendFromIndex; // The nearest previous frame index which blend mode is WEBP_MUX_BLEND @end @@ -719,8 +719,8 @@ static void FreeImageData(void *info, const void *data, size_t size) { frame.width = iter.width; frame.height = iter.height; frame.hasAlpha = iter.has_alpha; - frame.dispose = iter.dispose_method; - frame.blend = iter.blend_method; + frame.shouldDispose = iter.dispose_method == WEBP_MUX_DISPOSE_BACKGROUND; + frame.shouldBlend = iter.blend_method == WEBP_MUX_BLEND; frame.offsetX = iter.x_offset; frame.offsetY = canvasHeight - iter.y_offset - iter.height; @@ -728,11 +728,11 @@ static void FreeImageData(void *info, const void *data, size_t size) { BOOL offsetIsZero = (iter.x_offset == 0 && iter.y_offset == 0); frame.isFullSize = (sizeEqualsToCanvas && offsetIsZero); - if ((!frame.blend || !frame.hasAlpha) && frame.isFullSize) { + if ((!frame.shouldBlend || !frame.hasAlpha) && frame.isFullSize) { lastBlendIndex = iterIndex; frame.blendFromIndex = iterIndex; } else { - if (frame.dispose && frame.isFullSize) { + if (frame.shouldDispose && frame.isFullSize) { frame.blendFromIndex = lastBlendIndex; lastBlendIndex = iterIndex + 1; } else {