X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fswfcombine.c;h=e76b5c6a9977c7a707c8ed6431a8c45a244f0cb1;hb=e462d36034db2d5800e709456545087d50d14fb3;hp=4089f5b91fca9582a2475e2eb3f3404a6d0d0c59;hpb=4d5e2bc031fd25ce7c76fb0ba2b7da7c01d91eac;p=swftools.git diff --git a/src/swfcombine.c b/src/swfcombine.c index 4089f5b..e76b5c6 100644 --- a/src/swfcombine.c +++ b/src/swfcombine.c @@ -10,7 +10,6 @@ #include #include #include -#include #include "../lib/rfxswf.h" #include "../lib/args.h" #include "../lib/log.h" @@ -279,7 +278,7 @@ static void makestackmaster(SWF*swf) { SWF head; int ret; - int fi=open(slave_filename[t],O_RDONLY); + int fi=open(slave_filename[t],O_RDONLY|O_BINARY); TAG*tag; if(fi<0 || swf_ReadSWF(fi, &head)<0) { logf(" Couldn't open/read %s.", slave_filename[t]); @@ -487,17 +486,21 @@ void changedepth(TAG*tag, int add) PUT16(&tag->data[0],GET16(&tag->data[0])+add); } -void matrix_adjust(MATRIX*m, int movex, int movey, float scalex, float scaley) +void matrix_adjust(MATRIX*m, int movex, int movey, float scalex, float scaley, int scalepos) { m->sx = (int)(m->sx*scalex); m->sy = (int)(m->sy*scaley); - m->r0 = (int)(m->r0*scalex); - m->r1 = (int)(m->r1*scaley); + m->r1 = (int)(m->r1*scalex); + m->r0 = (int)(m->r0*scaley); + if(scalepos) { + m->tx *= scalex; + m->ty *= scaley; + } m->tx += movex; m->ty += movey; } -void write_changepos(TAG*output, TAG*tag, int movex, int movey, float scalex, float scaley) +void write_changepos(TAG*output, TAG*tag, int movex, int movey, float scalex, float scaley, int scalepos) { if(movex || movey || scalex != 1 || scaley != 1) { @@ -523,7 +526,7 @@ void write_changepos(TAG*output, TAG*tag, int movex, int movey, float scalex, fl } else { swf_GetMatrix(0, &m); } - matrix_adjust(&m, movex, movey, scalex, scaley); + matrix_adjust(&m, movex, movey, scalex, scaley, scalepos); swf_SetMatrix(output, &m); //swf_ResetReadBits(tag); @@ -536,7 +539,7 @@ void write_changepos(TAG*output, TAG*tag, int movex, int movey, float scalex, fl swf_SetU16(output, swf_GetU16(tag)); //depth swf_GetMatrix(tag, &m); - matrix_adjust(&m, movex, movey, scalex, scaley); + matrix_adjust(&m, movex, movey, scalex, scaley, scalepos); swf_SetMatrix(output, &m); //swf_ResetReadBits(tag); @@ -590,7 +593,7 @@ TAG* write_sprite(TAG*tag, SWF*sprite, int spriteid, int replaceddefine) logf(" [sprite main] write tag %02x (%d bytes in body)", rtag->id, rtag->len); tag = swf_InsertTag(tag, rtag->id); - write_changepos(tag, rtag, config.movex, config.movey, config.scalex, config.scaley); + write_changepos(tag, rtag, config.movex, config.movey, config.scalex, config.scaley, 0); changedepth(tag, +2); @@ -725,7 +728,7 @@ TAG* write_master(TAG*tag, SWF*master, SWF*slave, int spriteid, int replaceddefi logf(" [master] write tag %02x (%d bytes in body)", rtag->id, rtag->len); tag = swf_InsertTag(tag, rtag->id); - write_changepos(tag, rtag, config.mastermovex, config.mastermovey, config.masterscalex, config.masterscaley); + write_changepos(tag, rtag, config.mastermovex, config.mastermovey, config.masterscalex, config.masterscaley, 1); } } rtag = rtag->next; @@ -1071,7 +1074,7 @@ int main(int argn, char *argv[]) else { int ret; logf(" master entity %s (named \"%s\")\n", master_filename, master_name); - fi = open(master_filename, O_RDONLY); + fi = open(master_filename, O_RDONLY|O_BINARY); if(fi<0) { logf(" Failed to open %s\n", master_filename); exit(1); @@ -1136,7 +1139,7 @@ int main(int argn, char *argv[]) if(!config.dummy) { int ret; - fi = open(slave_filename[t], O_RDONLY); + fi = open(slave_filename[t], O_RDONLY|O_BINARY); if(!fi) { logf(" Failed to open %s\n", slave_filename[t]); exit(1); @@ -1163,7 +1166,7 @@ int main(int argn, char *argv[]) } } - fi = open(outputname, O_RDWR|O_TRUNC|O_CREAT, 0777); + fi = open(outputname, O_BINARY|O_RDWR|O_TRUNC|O_CREAT, 0777); if(config.zlib) swf_WriteSWC(fi, &newswf);