-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apng with region clearing #3
Comments
Thanks so much for this bug report - it makes total sense.
I'm not able to work on the code for a couple weeks as I'm travelling but I
will get to it (promise!).
Alternatively, I welcome PRs. :)
Thanks again!
…On 12 Apr 2017 5:17 pm, "marcos-dogonahorse" ***@***.***> wrote:
hi Aellerton,
I notice a bug while working with your wrapper around japng. It seems in
the latest code, you clear the whole screen every time the FrameController
return a 1 in the disposeOP ( PngAnimationComposer.java -> function
completeFrame(Argb8888Bitmap frameImage) )
The problem with that is that there are images that depend on the previous
screen being only partly clear. These reduces the png file size and is
completely supported by the APNG standers ( https://developer.mozilla.org/
en-US/docs/Mozilla/Tech/APNG#.27fcTL.27:_The_Frame_Control_Chunk
)
The solution to that problem is that you always only clear the region of
the next frame.
so this should be the new switch statement in that function:
`
switch (currentFrame.disposeOp) {
case 1: // APNG_DISPOSE_OP_BACKGROUND
Rect region = new Rect(currentFrame.xOffset, currentFrame.yOffset,
currentFrame.xOffset + currentFrame.width, currentFrame.yOffset +
currentFrame.height);
canvas.drawRect(region, clearModePaint);
break;
case 2: // APNG_DISPOSE_OP_PREVIOUS
//System.out.println(String.format("Frame %d restore previous (full=%s, x=%d y=%d w=%d h=%d) previous=%s", currentFrame.sequenceNumber,
// isFull, currentFrame.xOffset, currentFrame.yOffset, currentFrame.width, currentFrame.height, previous));
// Put the original section back
if (null != previous) {
//paint = new Paint();
//paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
paint = srcModePaint;
canvas.drawBitmap(previous, currentFrame.xOffset, currentFrame.yOffset, paint);
//System.out.println(" Restored previous "+previous.getWidth()+" x "+previous.getHeight());
previous.recycle();
} else {
System.out.println(" Huh, no previous?");
}
break;
case 0: // APNG_DISPOSE_OP_NONE
default: // Default should never happen
// do nothing
//System.out.println("Frame "+currentFrame.sequenceNumber+" do nothing dispose");
break;
}
`
clearModePaint is just a paint that i store from the constructor
this.clearModePaint = new Paint(); this.clearModePaint.setXfermode(new
PorterDuffXfermode(PorterDuff.Mode.CLEAR));
Here is an sample image that you can see the problem in:
[image: 12338-img-l-1491582573446 w400]
<https://cloud.githubusercontent.com/assets/13003036/24979875/e658e7c8-1fa3-11e7-908a-f1a201d38d52.png>
Thank you again for the wrapper 👍
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#3>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA7EolHhPVTY1mCKSWnr72iNVQOur6bqks5rvT-AgaJpZM4M7-5r>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi Aellerton,
I notice a bug while working with your wrapper around japng. It seems in the latest code, you clear the whole screen every time the FrameController return a 1 in the disposeOP ( PngAnimationComposer.java -> function completeFrame(Argb8888Bitmap frameImage) )
The problem with that is that there are images that depend on the previous screen being only partly clear. These reduces the png file size and is completely supported by the APNG standers ( https://developer.mozilla.org/en-US/docs/Mozilla/Tech/APNG#.27fcTL.27:_The_Frame_Control_Chunk
)
The solution to that problem is that you always only clear the region of the next frame.
so this should be the new switch statement in that function:
clearModePaint is just a paint that i store from the constructor
this.clearModePaint = new Paint(); this.clearModePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
Here is an sample image that you can see the problem in:
![12338-img-l-1491582573446 w400](https://cloud.githubusercontent.com/assets/13003036/24979875/e658e7c8-1fa3-11e7-908a-f1a201d38d52.png)
Thank you again for the wrapper 👍
The text was updated successfully, but these errors were encountered: