Fix the logic for Animated WebP images which contains a subsequence blend from the first frame, impact the `SDAnimatedImage`

This commit is contained in:
DreamPiggy 2019-05-14 20:50:17 +08:00
parent e5c9608ed6
commit c18c2c8757
1 changed files with 6 additions and 6 deletions

View File

@ -46,8 +46,8 @@
@property (nonatomic, assign) NSUInteger offsetY; // Frame origin.y in canvas (left-bottom based) @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 hasAlpha; // Whether frame contains alpha
@property (nonatomic, assign) BOOL isFullSize; // Whether frame size is equal to canvas size @property (nonatomic, assign) BOOL isFullSize; // Whether frame size is equal to canvas size
@property (nonatomic, assign) WebPMuxAnimBlend blend; // Frame dispose method @property (nonatomic, assign) BOOL shouldBlend; // Frame dispose method
@property (nonatomic, assign) WebPMuxAnimDispose dispose; // Frame blend operation @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 @property (nonatomic, assign) NSUInteger blendFromIndex; // The nearest previous frame index which blend mode is WEBP_MUX_BLEND
@end @end
@ -719,8 +719,8 @@ static void FreeImageData(void *info, const void *data, size_t size) {
frame.width = iter.width; frame.width = iter.width;
frame.height = iter.height; frame.height = iter.height;
frame.hasAlpha = iter.has_alpha; frame.hasAlpha = iter.has_alpha;
frame.dispose = iter.dispose_method; frame.shouldDispose = iter.dispose_method == WEBP_MUX_DISPOSE_BACKGROUND;
frame.blend = iter.blend_method; frame.shouldBlend = iter.blend_method == WEBP_MUX_BLEND;
frame.offsetX = iter.x_offset; frame.offsetX = iter.x_offset;
frame.offsetY = canvasHeight - iter.y_offset - iter.height; 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); BOOL offsetIsZero = (iter.x_offset == 0 && iter.y_offset == 0);
frame.isFullSize = (sizeEqualsToCanvas && offsetIsZero); frame.isFullSize = (sizeEqualsToCanvas && offsetIsZero);
if ((!frame.blend || !frame.hasAlpha) && frame.isFullSize) { if ((!frame.shouldBlend || !frame.hasAlpha) && frame.isFullSize) {
lastBlendIndex = iterIndex; lastBlendIndex = iterIndex;
frame.blendFromIndex = iterIndex; frame.blendFromIndex = iterIndex;
} else { } else {
if (frame.dispose && frame.isFullSize) { if (frame.shouldDispose && frame.isFullSize) {
frame.blendFromIndex = lastBlendIndex; frame.blendFromIndex = lastBlendIndex;
lastBlendIndex = iterIndex + 1; lastBlendIndex = iterIndex + 1;
} else { } else {