Skip to content
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

Fill only the area that was modified by the previous GIF frame #1093

Merged
merged 1 commit into from
Mar 25, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;

/**
* Reads frame data from a GIF image source and decodes it into individual frames
Expand Down Expand Up @@ -434,7 +433,15 @@ private Bitmap setPixels(GifFrame currentFrame, GifFrame previousFrame) {
c = 0;
}
}
Arrays.fill(dest, c);
// The area used by the graphic must be restored to the background color.
int topLeft = previousFrame.iy * width + previousFrame.ix;
int bottomLeft = topLeft + previousFrame.ih * width;
for (int left = topLeft; left < bottomLeft; left += width) {
int right = left + previousFrame.iw;
for (int pointer = left; pointer < right; pointer++) {
dest[pointer] = c;
}
}
} else if (previousFrame.dispose == DISPOSAL_PREVIOUS && previousImage != null) {
// Start with the previous frame
previousImage.getPixels(dest, 0, width, 0, 0, width, height);
Expand Down