added -s (--scale) option
[swftools.git] / src / png2swf.c
index 541675d..d2e495a 100644 (file)
@@ -41,6 +41,7 @@ struct {
     int do_cgi;
     int version;
     char *outfile;
+    float scale;
 } global;
 
 struct {
@@ -699,8 +700,8 @@ TAG *MovieAddFrame(SWF * swf, TAG * t, char *sname, int id)
 
     swf_ShapeNew(&s);
     swf_GetMatrix(NULL, &m);
-    m.sx = 20 * 0x10000;
-    m.sy = 20 * 0x10000;
+    m.sx = (int)(20 * 0x10000);
+    m.sy = (int)(20 * 0x10000);
     m.tx = -10;
     m.ty = -10;
     fs = swf_ShapeAddBitmapFillStyle(s, &m, id, 1);
@@ -728,12 +729,15 @@ TAG *MovieAddFrame(SWF * swf, TAG * t, char *sname, int id)
     t = swf_InsertTag(t, ST_PLACEOBJECT2);
 
     swf_GetMatrix(NULL, &m);
+    m.sx = (int)(0x10000 * global.scale);
+    m.sy = (int)(0x10000 * global.scale);
+
     if(custom_move) {
        m.tx = move_x*20;
        m.ty = move_y*20;
     } else {
-       m.tx = (swf->movieSize.xmax - (int) header.width * 20) / 2;
-       m.ty = (swf->movieSize.ymax - (int) header.height * 20) / 2;
+       m.tx = (swf->movieSize.xmax - (int) (header.width * global.scale * 20)) / 2;
+       m.ty = (swf->movieSize.ymax - (int) (header.height * global.scale * 20)) / 2;
     }
     swf_ObjectPlace(t, id + 1, 50, &m, NULL, NULL);
 
@@ -814,6 +818,11 @@ int args_callback_option(char *arg, char *val)
            res = 1;
            break;
 
+       case 's':
+           global.scale = atof(val)/100;
+           res = 1;
+           break;
+
        case 'z':
            global.version = 6;
            res = 0;
@@ -972,6 +981,7 @@ int main(int argc, char **argv)
     global.framerate = 1.0;
     global.verbose = 1;
     global.version = 4;
+    global.scale = 1.0;
 
     processargs(argc, argv);
     
@@ -984,10 +994,8 @@ int main(int argc, char **argv)
        fprintf(stderr, "Processing %i file(s)...\n", global.nfiles);
 
     t = MovieStart(&swf, global.framerate,
-                  global.force_width ? global.force_width : global.
-                  max_image_width,
-                  global.force_height ? global.force_height : global.
-                  max_image_height);
+                  global.force_width ? global.force_width : (int)(global.max_image_width*global.scale),
+                  global.force_height ? global.force_height : (int)(global.max_image_height*global.scale));
 
     {
        int i;