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

Fix swapped pixels in GifDecoder's output #3002

Merged
merged 1 commit into from
Apr 9, 2018
Merged
Show file tree
Hide file tree
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 @@ -766,8 +766,9 @@ private void decodeBitmapData(GifFrame frame) {
} else if (code == endOfInformation) {
break;
} else if (oldCode == NULL_CODE) {
pixelStack[top] = suffix[code];
++top;
mainPixels[pi] = suffix[code];
++pi;
++i;
oldCode = code;
first = code;
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ public void setUp() {
provider = new MockProvider();
}

@Test
public void testCorrectPixelsDecoded() throws IOException {
byte[] data = TestUtil.resourceToBytes(getClass(), "white_black_row.gif");
GifHeaderParser headerParser = new GifHeaderParser();
headerParser.setData(data);
GifHeader header = headerParser.parseHeader();
GifDecoder decoder = new StandardGifDecoder(provider);
decoder.setData(header, data);
decoder.advance();
Bitmap bitmap = decoder.getNextFrame();
assertNotNull(bitmap);
assertEquals(bitmap.getPixel(2, 0), bitmap.getPixel(0, 0));
assertEquals(bitmap.getPixel(3, 0), bitmap.getPixel(1, 0));
}

@Test
public void testCanDecodeFramesFromTestGif() throws IOException {
byte[] data = TestUtil.resourceToBytes(getClass(), "partial_gif_decode.gif");
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.