+ }
+
+ return true;
+}
+
+bool wxGIFHandler_WriteControl(wxOutputStream *stream,
+ int maskIndex, int delayMilliSecs)
+{
+ wxUint8 buf[8];
+
+ 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[6] = (maskIndex != wxNOT_FOUND) ? (wxUint8) maskIndex : 0;
+ buf[7] = 0;
+ return wxGIFHandler_Write(stream, buf, sizeof(buf));
+}
+
+bool wxGIFHandler_WriteComment(wxOutputStream *stream, const wxString& comment)
+{
+ wxUint8 buf[3];
+ wxCharBuffer text(comment.mb_str());
+ size_t len = strlen(text.data());
+ len = wxMin(len, 255);
+
+ buf[0] = GIF_MARKER_EXT;
+ buf[1] = GIF_MARKER_EXT_COMMENT;
+ buf[2] = (wxUint8)len;
+
+ return wxGIFHandler_Write(stream, buf, sizeof(buf))
+ && wxGIFHandler_Write(stream, text.data(), len)
+ && wxGIFHandler_WriteZero(stream);
+}
+
+bool wxGIFHandler_WriteLoop(wxOutputStream *stream)
+{
+ wxUint8 buf[4];
+ const int loopcount = 0; // infinite
+
+ buf[0] = GIF_MARKER_EXT;
+ buf[1] = GIF_MARKER_EXT_APP;
+ buf[2] = 0x0B;
+ bool ok = wxGIFHandler_Write(stream, buf, 3)
+ && wxGIFHandler_Write(stream, NETSCAPE_LOOP, sizeof(NETSCAPE_LOOP)-1);
+
+ buf[0] = 3;
+ buf[1] = 1;
+ buf[2] = loopcount & 0xFF;
+ buf[3] = loopcount >> 8;
+
+ return ok && wxGIFHandler_Write(stream, buf, 4)
+ && wxGIFHandler_WriteZero(stream);
+}