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
This commit is contained in:
Vadim Zeitlin 2014-07-25 17:34:27 +00:00
parent 03275cc759
commit be0dcf769f

View File

@ -721,13 +721,14 @@ bool wxGIFHandler_WriteControl(wxOutputStream *stream,
int maskIndex, int delayMilliSecs) int maskIndex, int delayMilliSecs)
{ {
wxUint8 buf[8]; wxUint8 buf[8];
const wxUint16 delay = delayMilliSecs / 10;
buf[0] = GIF_MARKER_EXT; // extension marker buf[0] = GIF_MARKER_EXT; // extension marker
buf[1] = GIF_MARKER_EXT_GRAPHICS_CONTROL; buf[1] = GIF_MARKER_EXT_GRAPHICS_CONTROL;
buf[2] = 4; // length of block buf[2] = 4; // length of block
buf[3] = (maskIndex != wxNOT_FOUND) ? 1 : 0; // has transparency buf[3] = (maskIndex != wxNOT_FOUND) ? 1 : 0; // has transparency
buf[4] = delayMilliSecs / 10; // delay time buf[4] = delay & 0xff; // delay time
buf[5] = 0; buf[5] = (delay >> 8) & 0xff; // delay time second byte
buf[6] = (maskIndex != wxNOT_FOUND) ? (wxUint8) maskIndex : 0; buf[6] = (maskIndex != wxNOT_FOUND) ? (wxUint8) maskIndex : 0;
buf[7] = 0; buf[7] = 0;
return wxGIFHandler_Write(stream, buf, sizeof(buf)); return wxGIFHandler_Write(stream, buf, sizeof(buf));