-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
When animating with this APNG:
https://en.wikipedia.org/wiki/File:Animated_PNG_example_bouncing_beach_ball.png
Visible artifacts can be seen (dragging blue trail on bouncing ball). This is caused by not properly handling the "dispose_op" value (specifically, when "dispose_op" has value of "1":
https://wiki.mozilla.org/APNG_Specification#.60fcTL.60:_The_Frame_Control_Chunk
Here is my fix:
PngAnimationComposer.java
...
private PngFrameControl currentFrame;
private PngFrameControl previousFrame;
...
public void completeFrame(Argb8888Bitmap frameImage) {
Bitmap frame = PngAndroid.toBitmap(frameImage);
Paint paint = null;
Drawable d;
Bitmap previous=null;
if(previousFrame != null) {
if (1 == previousFrame.disposeOp) {
canvas.drawColor(0, PorterDuff.Mode.CLEAR);
}
if (2 == previousFrame.disposeOp) {
previous = Bitmap.createBitmap(canvasBitmap, currentFrame.xOffset, currentFrame.yOffset, currentFrame.width, currentFrame.height); // or could use from frames?
}
}
if (0 == currentFrame.blendOp) {
paint = srcModePaint;
}
...
previousFrame = currentFrame;
currentFrame = null;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels