X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fswfcombine.c;h=e76b5c6a9977c7a707c8ed6431a8c45a244f0cb1;hb=3bb9dfe334b48568c45a688a8ac5c1cce021a75d;hp=628825d90c370a0056ac46bbc10181962331aefe;hpb=bd9310ce0e8ac12bc50ae077d8b2face9b53ca79;p=swftools.git diff --git a/src/swfcombine.c b/src/swfcombine.c index 628825d..e76b5c6 100644 --- a/src/swfcombine.c +++ b/src/swfcombine.c @@ -278,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]); @@ -486,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->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) { @@ -522,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); @@ -535,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); @@ -589,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); @@ -724,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; @@ -1070,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); @@ -1135,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); @@ -1162,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);