* fixed swf_CopySWF
[swftools.git] / lib / rfxswf.c
index f0ece33..2f80c88 100644 (file)
@@ -542,11 +542,11 @@ void swf_ExpandRect3(SRECT*src, SPOINT center, int radius)
     if(center.x - radius < src->xmin)
        src->xmin = center.x - radius;
     if(center.x + radius > src->xmax)
-       src->xmax = center.x - radius;
+       src->xmax = center.x + radius;
     if(center.y - radius < src->ymin)
        src->ymin = center.y - radius;
     if(center.y + radius > src->ymax)
-       src->ymax = center.y - radius;
+       src->ymax = center.y + radius;
 }
 SPOINT swf_TurnPoint(SPOINT p, MATRIX* m)
 {
@@ -1311,9 +1311,11 @@ int  swf_WriteSWF2(struct writer_t*writer, SWF * swf)     // Writes SWF to file,
 
 #ifdef INSERT_RFX_TAG
 
-  if (swf->firstTag && swf_NextTag(swf->firstTag))
-    if (swf_GetTagID(swf_NextTag(swf->firstTag))!=ST_REFLEX)
+  if (swf->firstTag && swf->firstTag->next &&
+      (swf->firstTag->id != ST_REFLEX || swf->firstTag->next->id != ST_REFLEX)
+     ) {
       swf_SetBlock(swf_InsertTagBefore(swf, swf->firstTag,ST_REFLEX),"rfx",3);
+  }
 
 #endif // INSERT_RFX_TAG
 
@@ -1488,6 +1490,22 @@ int swf_WriteCGI(SWF * swf)
   return swf_WriteSWF(fileno(stdout),swf);
 }
 
+SWF* swf_CopySWF(SWF*swf)
+{
+    SWF*nswf = rfx_alloc(sizeof(SWF));
+    memcpy(nswf, swf, sizeof(SWF));
+    nswf->firstTag = 0;
+    TAG*tag = swf->firstTag;
+    TAG*ntag = 0;
+    while(tag) {
+        ntag = swf_CopyTag(ntag, tag);
+        if(!nswf->firstTag)
+            nswf->firstTag = ntag;
+        tag = tag->next;
+    }
+    return nswf;
+}
+
 void swf_FreeTags(SWF * swf)                 // Frees all malloc'ed memory for tags
 { TAG * t = swf->firstTag;
 
@@ -1514,3 +1532,4 @@ void swf_FreeTags(SWF * swf)                 // Frees all malloc'ed memory for t
 #include "modules/swfaction.c"
 #include "modules/swfsound.c"
 #include "modules/swfdraw.c"
+#include "modules/swfrender.c"