new option -E.
[swftools.git] / src / swfdump.c
index a697900..294a3f2 100644 (file)
@@ -51,21 +51,25 @@ static char * indent = "                ";
 static int placements = 0;
 static int action = 0;
 static int html = 0;
+static int xhtml = 0;
 static int xy = 0;
 static int showtext = 0;
 static int showshapes = 0;
 static int hex = 0;
 static int used = 0;
+static int bbox = 0;
 
 static struct options_t options[] = {
 {"h", "help"},
 {"D", "full"},
 {"V", "version"},
 {"e", "html"},
+{"E", "xhtml"},
 {"a", "action"},
 {"t", "text"},
 {"s", "shapes"},
 {"p", "placements"},
+{"b", "bbox"},
 {"X", "width"},
 {"Y", "height"},
 {"r", "rate"},
@@ -101,6 +105,11 @@ int args_callback_option(char*name,char*val)
         html = 1;
         return 0;
     }
+    else if(name[0]=='E') {
+        html = 1;
+        xhtml = 1;
+        return 0;
+    }
     else if(name[0]=='X') {
        xy |= 1;
        return 0;
@@ -125,6 +134,10 @@ int args_callback_option(char*name,char*val)
        used = 1;
        return 0;
     }
+    else if(name[0]=='b') {
+       bbox = 1;
+       return 0;
+    }
     else if(name[0]=='D') {
        action = placements = showtext = showshapes = 1;
        return 0;
@@ -153,6 +166,7 @@ void args_callback_usage(char *name)
     printf("-t , --text                    Show text fields (like swfstrings).\n");
     printf("-s , --shapes                  Show shape coordinates/styles\n");
     printf("-p , --placements              Show placement information\n");
+    printf("-b , --bbox                    Print tag's bounding boxes\n");
     printf("-X , --width                   Prints out a string of the form \"-X width\".\n");
     printf("-Y , --height                  Prints out a string of the form \"-Y height\".\n");
     printf("-r , --rate                    Prints out a string of the form \"-r rate\".\n");
@@ -809,23 +823,34 @@ int main (int argc,char ** argv)
            fprintf(stderr, "Fileversion>9\n");
            exit(1);
        }
-       printf("<OBJECT CLASSID=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"\n"
-              " WIDTH=\"%d\"\n"
-              //" BGCOLOR=#ffffffff\n"?
-              " HEIGHT=\"%d\"\n"
-              //http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,23,0?
-              " CODEBASE=\"http://active.macromedia.com/flash5/cabs/swflash.cab#version=%s\">\n"
-               "  <PARAM NAME=\"MOVIE\" VALUE=\"%s\">\n"
-              "  <PARAM NAME=\"PLAY\" VALUE=\"true\">\n" 
-              "  <PARAM NAME=\"LOOP\" VALUE=\"true\">\n"
-              "  <PARAM NAME=\"QUALITY\" VALUE=\"high\">\n"
-              "  <EMBED SRC=\"%s\" WIDTH=\"%d\" HEIGHT=\"%d\"\n" //bgcolor=#ffffff?
-              "   PLAY=\"true\" ALIGN=\"\" LOOP=\"true\" QUALITY=\"high\"\n"
-              "   TYPE=\"application/x-shockwave-flash\"\n"
-              "   PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\">\n"
-               "  </EMBED>\n" 
-              "</OBJECT>\n", xsize, ysize, fileversions[swf.fileVersion], 
-                             filename, filename, xsize, ysize);
+
+       if(xhtml) {
+           printf("<object type=\"application/x-shockwave-flash\" data=\"%s\" width=\"%d\" height=\"%d\">\n"
+                           "<param name=\"movie\" value=\"%s\"/>\n"
+                           "<param name=\"play\" value=\"true\"/>\n"
+                           "<param name=\"loop\" value=\"false\"/>\n"
+                           "<param name=\"quality\" value=\"high\"/>\n"
+                           "<param name=\"loop\" value=\"false\"/>\n"
+                           "</object>\n\n", filename, xsize, ysize, filename);
+       } else {
+           printf("<OBJECT CLASSID=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"\n"
+                  " WIDTH=\"%d\"\n"
+                  //" BGCOLOR=#ffffffff\n"?
+                  " HEIGHT=\"%d\"\n"
+                  //http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,23,0?
+                  " CODEBASE=\"http://active.macromedia.com/flash5/cabs/swflash.cab#version=%s\">\n"
+                  "  <PARAM NAME=\"MOVIE\" VALUE=\"%s\">\n"
+                  "  <PARAM NAME=\"PLAY\" VALUE=\"true\">\n" 
+                  "  <PARAM NAME=\"LOOP\" VALUE=\"true\">\n"
+                  "  <PARAM NAME=\"QUALITY\" VALUE=\"high\">\n"
+                  "  <EMBED SRC=\"%s\" WIDTH=\"%d\" HEIGHT=\"%d\"\n" //bgcolor=#ffffff?
+                  "   PLAY=\"true\" ALIGN=\"\" LOOP=\"true\" QUALITY=\"high\"\n"
+                  "   TYPE=\"application/x-shockwave-flash\"\n"
+                  "   PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\">\n"
+                  "  </EMBED>\n" 
+                  "</OBJECT>\n", xsize, ysize, fileversions[swf.fileVersion], 
+                                 filename, filename, xsize, ysize);
+       }
        return 0;
     } 
     printf("[HEADER]        File version: %d\n", swf.fileVersion);
@@ -909,8 +934,16 @@ int main (int argc,char ** argv)
                printf(" object");
 
             printf(" at depth %04d", swf_GetDepth(tag));
+           
+           if(tag->data[0]&64) {
+               SWFPLACEOBJECT po;
+               swf_GetPlaceObject(tag, &po);
+               printf(" (clip to %04d)", po.clipdepth);
+               swf_PlaceObjectFree(&po);
+           }
             if(swf_GetName(tag))
                 printf(" name \"%s\"",swf_GetName(tag));
+
        }
         else if(tag->id == ST_REMOVEOBJECT) {
             printf(" removes id %04d from depth %04d", swf_GetPlaceID(tag), swf_GetDepth(tag));
@@ -1035,6 +1068,15 @@ int main (int argc,char ** argv)
        else {
            printf("\n");
        }
+
+       if(bbox && swf_isDefiningTag(tag) && tag->id != ST_DEFINESPRITE) {
+           SRECT r = swf_GetDefineBBox(tag);
+           printf("                %s bbox [%.2f, %.2f, %.2f, %.2f]\n", prefix,
+                   r.xmin/20.0,
+                   r.ymin/20.0,
+                   r.xmax/20.0,
+                   r.ymax/20.0);
+       }
         
         sprintf(myprefix, "                %s", prefix);