+enum disposal_method {
+ NONE,
+ DO_NOT_DISPOSE,
+ RESTORE_TO_BGCOLOR,
+ RESTORE_TO_PREVIOUS
+};
+
+
+void SetFrameAction(TAG ** t, const char *src, int ver)
+{
+ ActionTAG *as;
+
+ as = swf_ActionCompile(src, ver);
+ if (!as)
+ fprintf(stderr, "Couldn't compile ActionScript\n");
+ else {
+ *t = swf_InsertTag(*t, ST_DOACTION);
+ swf_ActionSet(*t, as);
+ swf_ActionFree(as);
+ }
+}
+
+int getGifDisposalMethod(GifFileType * gft, int framenum)
+{
+ int i;
+ ExtensionBlock *ext = gft->SavedImages[framenum].ExtensionBlocks;
+
+ for (i = 0; i < gft->SavedImages[framenum].ExtensionBlockCount; i++, ext++)
+ if (ext->Function == GRAPHICS_EXT_FUNC_CODE)
+ return ((ext->Bytes[0] & 0x1C) >> 2);
+
+ return -1;
+}
+
+int getGifLoopCount(GifFileType * gft)
+{
+ int i, loop = -1;
+ ExtensionBlock *ext = gft->SavedImages[0].ExtensionBlocks;
+
+ for (i = 0; i < gft->SavedImages[0].ExtensionBlockCount; i++, ext++)
+ if (ext->Function == APPLICATION_EXT_FUNC_CODE) {
+ // info: http://semmix.pl/color/exgraf/eeg24.htm
+ if (ext->ByteCount == 11 &&
+ (strncmp(&ext->Bytes[0], "NETSCAPE2.0", 11) == 0 ||
+ strncmp(&ext->Bytes[0], "ANIMEXTS1.0", 11) == 0)) {
+ // check for the subblock
+ ext++;
+ if (ext->ByteCount != 3)
+ ext--;
+ else {
+ loop = GET16(&ext->Bytes[1]);
+ break;
+ }
+ }
+ }
+
+ return loop;
+}
+
+U16 getGifDelayTime(GifFileType * gft, int framenum)
+{
+ int i;
+ ExtensionBlock *ext = gft->SavedImages[framenum].ExtensionBlocks;