Skip to content

Commit

Permalink
Fix swapped pixels in GifDecoder's output (#3002)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marko Topolnik authored and sjudd committed Apr 9, 2018
1 parent 6e932b3 commit 7fb8b12
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
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.

0 comments on commit 7fb8b12

Please sign in to comment.