From be0dcf769f475c203cd42c2e24f6ea442990ddb5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 25 Jul 2014 17:34:27 +0000 Subject: [PATCH] Write delay between frames correctly when saving GIF files. Deal with delays greater than ~2.5s correctly, their most significant byte was previously lost resulting in 0 delay being written to the file. Closes #16392. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76952 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/imaggif.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/imaggif.cpp b/src/common/imaggif.cpp index 9c0f8bea3a..ba2f3bbc0d 100644 --- a/src/common/imaggif.cpp +++ b/src/common/imaggif.cpp @@ -721,13 +721,14 @@ bool wxGIFHandler_WriteControl(wxOutputStream *stream, int maskIndex, int delayMilliSecs) { wxUint8 buf[8]; + const wxUint16 delay = delayMilliSecs / 10; buf[0] = GIF_MARKER_EXT; // extension marker buf[1] = GIF_MARKER_EXT_GRAPHICS_CONTROL; buf[2] = 4; // length of block buf[3] = (maskIndex != wxNOT_FOUND) ? 1 : 0; // has transparency - buf[4] = delayMilliSecs / 10; // delay time - buf[5] = 0; + buf[4] = delay & 0xff; // delay time + buf[5] = (delay >> 8) & 0xff; // delay time second byte buf[6] = (maskIndex != wxNOT_FOUND) ? (wxUint8) maskIndex : 0; buf[7] = 0; return wxGIFHandler_Write(stream, buf, sizeof(buf));