diff options
author | Sam Judd <judds@google.com> | 2014-10-21 19:31:46 -0700 |
---|---|---|
committer | Sam Judd <judds@google.com> | 2014-10-21 19:31:46 -0700 |
commit | 4fcb6cd5b3dbd7ecc58d3e3dcb7a3d8304e54a16 (patch) | |
tree | 4b4fca82227416189be4f66af5b9c01d420eb5de /third_party/gif_decoder/src/androidTest/java/com/bumptech/glide/gifdecoder/test/GifBytesTestUtil.java | |
parent | 39f12e09c7273b13604184e523846c1ef18ff311 (diff) | |
download | glide-4fcb6cd5b3dbd7ecc58d3e3dcb7a3d8304e54a16.tar.gz |
Set minimum and default frame delays.
Fixes #205.
Diffstat (limited to 'third_party/gif_decoder/src/androidTest/java/com/bumptech/glide/gifdecoder/test/GifBytesTestUtil.java')
-rw-r--r-- | third_party/gif_decoder/src/androidTest/java/com/bumptech/glide/gifdecoder/test/GifBytesTestUtil.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/third_party/gif_decoder/src/androidTest/java/com/bumptech/glide/gifdecoder/test/GifBytesTestUtil.java b/third_party/gif_decoder/src/androidTest/java/com/bumptech/glide/gifdecoder/test/GifBytesTestUtil.java index e389deed..b6f3140e 100644 --- a/third_party/gif_decoder/src/androidTest/java/com/bumptech/glide/gifdecoder/test/GifBytesTestUtil.java +++ b/third_party/gif_decoder/src/androidTest/java/com/bumptech/glide/gifdecoder/test/GifBytesTestUtil.java @@ -10,6 +10,8 @@ public class GifBytesTestUtil { public static final int HEADER_LENGTH = 13; // Length in bytes. public static final int IMAGE_DESCRIPTOR_LENGTH = 10; + // Length in bytes. + public static final int GRAPHICS_CONTROL_EXTENSION_LENGTH = 8; public static int getColorTableLength(int numColors) { return 3 * numColors; @@ -104,6 +106,29 @@ public class GifBytesTestUtil { out.put((byte) 0); } + public static void writeGraphicsControlExtension(ByteBuffer out, int delayTime) { + verifyRemaining(out, GRAPHICS_CONTROL_EXTENSION_LENGTH); + verifyShortValues(delayTime); + + // Extension inducer (constant). + out.put((byte) 0x21); + // Graphic control label (constant). + out.put((byte) 0xF9); + // Block size (constant). + out.put((byte) 0x04); + // Packed (disposal method, user input, transparent color flag) + out.put((byte) 0x00); + + // Frame delay in 100ths of a second. + out.putShort((short) delayTime); + + // Transparent color index. + out.put((byte) 0x00); + + // Block terminator (constant). + out.put((byte) 0x00); + } + private static void verifyRemaining(ByteBuffer buffer, int expected) { if (buffer.remaining() < expected) { throw new IllegalArgumentException("Must have at least " + expected + " bytes to write"); |