new function swf_GetMorphGradient
[swftools.git] / lib / rfxswf.c
index 6a8d79d..4a7035c 100644 (file)
@@ -31,6 +31,9 @@
 #endif // HAVE_ZLIB_H
 #endif // HAVE_LIBZ
 
+#define LAME
+#include "lame/lame.h"
+
 #include "./bitio.h"
 
 // internal constants
@@ -295,6 +298,29 @@ void swf_GetGradient(TAG * tag, GRADIENT * gradient, char alpha)
     }
 }
 
+void swf_GetMorphGradient(TAG * tag, GRADIENT * gradient1, GRADIENT * gradient2)
+{
+    GRADIENT dummy1;
+    GRADIENT dummy2;
+    int t;
+    if(!gradient1)
+       gradient1 = &dummy1;
+    if(!gradient2)
+       gradient2 = &dummy2;
+    gradient1->num = 
+    gradient2->num = swf_GetU8(tag);
+    for(t=0;t<gradient1->num;t++)
+    {
+       int s=t;
+       if(s>=8) //FIXME
+           s=7;
+       gradient1->ratios[t] = swf_GetU8(tag);
+       swf_GetRGBA(tag, &gradient1->rgba[t]);
+       gradient2->ratios[t] = swf_GetU8(tag);
+       swf_GetRGBA(tag, &gradient2->rgba[t]);
+    }
+}
+
 int swf_CountBits(U32 v,int nbits)
 { int n = 33;
   U32 m = 0x80000000;
@@ -747,6 +773,10 @@ void swf_FoldSprite(TAG * t)
       fprintf(stderr, "Error: Sprite has no ID!");
       return;
   }
+  if(t->len>4) {
+    /* sprite is already folded */
+      return;
+  }
 
   t->pos = 0;
   id = swf_GetU16(t);
@@ -838,7 +868,7 @@ int swf_ReadSWF2(struct reader_t*reader, SWF * swf)   // Reads SWF to memory (ma
     t1.next->prev = NULL;
   }
   
-  return 0;
+  return reader->pos;
 }
 
 int swf_ReadSWF(int handle, SWF * swf)