added build rule for swfedit
[swftools.git] / src / swfdump.c
index 99917eb..3978d5c 100644 (file)
@@ -319,7 +319,7 @@ SWFFONT**fonts;
 void textcallback(void*self, int*glyphs, int*ypos, int nr, int fontid, int fontsize, int startx, int starty, RGBA*color) 
 {
     int font=-1,t;
-    printf("                <%2d glyphs in font %2d, color #%02x%02x%02x%02x> ",nr, fontid, color->r, color->g, color->b, color->a);
+    printf("                <%2d glyphs in font %2d size %d, color #%02x%02x%02x%02x> ",nr, fontid, fontsize, color->r, color->g, color->b, color->a);
     for(t=0;t<fontnum;t++)
     {
        if(fonts[t]->id == fontid) {
@@ -538,6 +538,15 @@ void dumpFilter(FILTER*filter)
        FILTER_BLUR*f = (FILTER_BLUR*)filter;
        printf("blurx: %f blury: %f\n", f->blurx, f->blury);
        printf("passes: %d\n", f->passes);
+    } if(filter->type == FILTERTYPE_GLOW) {
+       FILTER_GLOW*f = (FILTER_GLOW*)filter;
+       printf("color %02x%02x%02x%02x\n", f->rgba.r,f->rgba.g,f->rgba.b,f->rgba.a);
+       printf("blurx: %f blury: %f strength: %f\n", f->blurx, f->blury, f->strength);
+       printf("passes: %d\n", f->passes);
+       printf("flags: %s%s%s\n", 
+               f->knockout?"knockout ":"",
+               f->composite?"composite ":"",
+               f->innerglow?"innerglow":"");
     } if(filter->type == FILTERTYPE_DROPSHADOW) {
        FILTER_DROPSHADOW*f = (FILTER_DROPSHADOW*)filter;
        printf("blurx: %f blury: %f\n", f->blurx, f->blury);
@@ -926,7 +935,6 @@ int main (int argc,char ** argv)
     }
 
     f = open(filename,O_RDONLY|O_BINARY);
-
     if (f<0)
     { 
        char buffer[256];
@@ -934,6 +942,12 @@ int main (int argc,char ** argv)
         perror(buffer);
         exit(1);
     }
+    char header[3];
+    read(f, header, 3);
+    int compressed = (header[0]=='C');
+    close(f);
+    f = open(filename,O_RDONLY|O_BINARY);
+
     if FAILED(swf_ReadSWF(f,&swf))
     { 
         fprintf(stderr, "%s is not a valid SWF file or contains errors.\n",filename);
@@ -943,7 +957,7 @@ int main (int argc,char ** argv)
 
 #ifdef HAVE_STAT
     fstat(f, &statbuf);
-    if(statbuf.st_size != swf.fileSize && !swf.compressed)
+    if(statbuf.st_size != swf.fileSize && !compressed)
         dumperror("Real Filesize (%d) doesn't match header Filesize (%d)",
                 statbuf.st_size, swf.fileSize);
     filesize = statbuf.st_size;
@@ -951,6 +965,11 @@ int main (int argc,char ** argv)
 
     close(f);
 
+    //if(action && swf.fileVersion>=9) {
+    //    fprintf(stderr, "Actionscript parsing (-a) not yet supported for SWF versions>=9\n");
+    //    action = 0;
+    //}
+
     xsize = (swf.movieSize.xmax-swf.movieSize.xmin)/20;
     ysize = (swf.movieSize.ymax-swf.movieSize.ymin)/20;
     if(xy)
@@ -1018,7 +1037,7 @@ int main (int argc,char ** argv)
        return 0;
     } 
     printf("[HEADER]        File version: %d\n", swf.fileVersion);
-    if(swf.compressed) {
+    if(compressed) {
        printf("[HEADER]        File is zlib compressed.");
        if(filesize && swf.fileSize)
            printf(" Ratio: %02d%%\n", filesize*100/(swf.fileSize));
@@ -1246,6 +1265,12 @@ int main (int argc,char ** argv)
            else
                printf("\n");
        }
+       else if(tag->id == ST_DEFINESCALINGGRID) {
+           U16 id = swf_GetU16(tag);
+           SRECT r;
+           swf_GetRect(tag, &r);
+           printf(" (%.2f,%.2f)-(%.2f,%.2f)\n", r.xmin/20.0, r.ymin/20.0, r.xmax/20.0, r.ymax/20.0);
+       }
        else if(tag->id == ST_PLACEOBJECT2 || tag->id == ST_PLACEOBJECT3) {
        }
        else if(tag->id == ST_NAMECHARACTER || tag->id==ST_DEFINEFONTNAME) {
@@ -1291,6 +1316,9 @@ int main (int argc,char ** argv)
             actions = swf_ActionGet(tag);
             swf_DumpActions(actions, myprefix);
         }
+        else if(tag->id == ST_DOABC && action) {
+            swf_DissassembleABC(tag);
+        }
         else if(tag->id == ST_DOINITACTION && action) {
             ActionTAG*actions;
             swf_GetU16(tag); // id