added -b, -B flags.
authorkramm <kramm>
Fri, 3 Sep 2004 20:18:13 +0000 (20:18 +0000)
committerkramm <kramm>
Fri, 3 Sep 2004 20:18:13 +0000 (20:18 +0000)
src/swfbbox.c
src/swfbbox.doc

index fcb11d0..b8facd0 100644 (file)
@@ -35,6 +35,7 @@ static int optimize = 0;
 static int swifty = 0;
 static int verbose = 0;
 static int showbbox = 1;
+static int showorigbbox = 0;
 static int expand = 1;
 
 static struct options_t options[] = {
@@ -42,6 +43,8 @@ static struct options_t options[] = {
 {"O", "optimize"},
 {"S", "swifty"},
 {"o", "output"},
+{"b", "bbox"},
+{"B", "newbbox"},
 {"e", "expand"},
 {"v", "verbose"},
 {"V", "version"},
@@ -54,20 +57,33 @@ int args_callback_option(char*name,char*val)
         printf("swfbbox - part of %s %s\n", PACKAGE, VERSION);
         exit(0);
     } 
+    else if(!strcmp(name, "b")) {
+       showorigbbox = 1;
+       if(showbbox == 1) showbbox = 0;
+       return 0;
+    } 
+    else if(!strcmp(name, "B")) {
+       showbbox = 2;
+       return 0;
+    } 
     else if(!strcmp(name, "O")) {
        optimize = 1;
-       showbbox = 0;
+       if(showbbox == 1) showbbox = 0;
        return 0;
     } 
     else if(!strcmp(name, "S")) {
        swifty = 1;
-       showbbox = 0;
+       if(showbbox == 1) showbbox = 0;
        return 0;
     } 
     else if(!strcmp(name, "v")) {
        verbose ++;
        return 0;
     } 
+    else if(!strcmp(name, "q")) {
+       verbose --;
+       return 0;
+    } 
     else if(!strcmp(name, "e")) {
        expand = 1;
        return 0;
@@ -406,6 +422,7 @@ int main (int argc,char ** argv)
     TAG*tag;
     SWF swf;
     int fi;
+    SRECT oldMovieSize;
     SRECT newMovieSize;
     memset(bboxes, 0, sizeof(bboxes));
     memset(depth2name, 0, sizeof(depth2name));
@@ -467,6 +484,7 @@ int main (int argc,char ** argv)
        showSwiftyOutput(&swf);
     }
 
+    oldMovieSize = swf.movieSize;
     newMovieSize = getSWFBBox(&swf);
 
     if(optimize || expand) {
@@ -484,13 +502,25 @@ int main (int argc,char ** argv)
     }
     
     if(showbbox) {
-       printf("Real Movie Size: %.2fx%.2f (:%.2f:%.2f)\n", 
+       if(verbose>=0)
+           printf("Real Movie Size: ");
+       printf("%.2f x %.2f :%.2f :%.2f\n", 
                (newMovieSize.xmax-newMovieSize.xmin)/20.0,
                (newMovieSize.ymax-newMovieSize.ymin)/20.0,
                (newMovieSize.xmin)/20.0,
                (newMovieSize.ymin)/20.0
                );
     }
+    if(showorigbbox) {
+       if(verbose>=0)
+           printf("Original Movie Size: ");
+       printf("%.2f x %.2f :%.2f :%.2f\n", 
+               (oldMovieSize.xmax-oldMovieSize.xmin)/20.0,
+               (oldMovieSize.ymax-oldMovieSize.ymin)/20.0,
+               (oldMovieSize.xmin)/20.0,
+               (oldMovieSize.ymin)/20.0
+               );
+    }
 
     swf_FreeTags(&swf);
     return 0;
index be44d72..3f165e8 100644 (file)
@@ -9,6 +9,12 @@ It can also dump the corners of the bounding boxes of all frames of a movie.
 
 -h, --help 
     Print help and exit
+-b, --bbox
+    Show movie bounding box (default)
+-B, --newbbox
+    Show recalculated (optimized/expanded) bounding box
+-e, --expand
+    Write out a new file using the recalculated bounding box
 -O, --optimize 
     Recalculate bounding boxes
 -S, --swifty