* fixed gradient reading
[swftools.git] / src / combine.c
index 3483041..9530bb7 100644 (file)
@@ -157,8 +157,15 @@ void write_sprite_defines(struct writer_t*w)
                         * Anyway we can't throw it out, so we just pass it
                         * through.
                         */
+                       writer_write(w, tag->fulldata, tag->fulllength);
                        break;
                    }
+                case TAGID_JPEGTABLES:
+                       /* according to the flash specs, there may only 
+                          be one JPEGTABLES tag per swf. This is maybe
+                          a big FIXME */
+                       writer_write(w, tag->fulldata, tag->fulllength);
+                   break;
                 case TAGID_EXPORTASSETS:
                    logf("<debug> deliberately ignoring EXPORTASSETS tag");
                    break;
@@ -303,6 +310,30 @@ void write_master(struct writer_t*w, int spriteid, int replaceddefine, int flags
     while(master.tags[pos++].id != 0);
 }
 
+void writeheader(struct writer_t*w, u8*data, int length)
+{
+    if(config.hassizex || config.hassizey || config.framerate)
+    {
+       struct flash_header head;
+       swf_init(data-3, length+3);
+       head = swf_read_header();
+       if(config.hassizex)
+       {
+           head.boundingBox.x2 = head.boundingBox.x1 + config.sizex;
+       }
+       if(config.hassizey)
+       {
+           head.boundingBox.y2 = head.boundingBox.y1 + config.sizey;
+       }
+       if(config.framerate)
+       {
+           head.rate = config.framerate;
+       }
+       swf_write_header(w, &head);
+    }
+    else
+    writer_write(w, data, length);
+}
 
 uchar * combine(uchar*masterdata, int masterlength, char*_slavename, uchar*slavedata, int slavelength, int*newlength)
 {
@@ -334,6 +365,9 @@ uchar * combine(uchar*masterdata, int masterlength, char*_slavename, uchar*slave
        logf("<notice> the master file is flash (swf) format\n");
        master_flash = 1;
     }
+    else
+       logf("<notice> the master file is not flash (swf) format!\n");
+
     if(slavedata[2] == 'S' &&
        slavedata[1] == 'W' &&
        slavedata[0] == 'F')
@@ -341,6 +375,8 @@ uchar * combine(uchar*masterdata, int masterlength, char*_slavename, uchar*slave
        logf("<notice> the slave file is flash (swf) format\n");
        slave_flash = 1;
     }
+    else
+       logf("<notice> the slave file is not flash (swf) format!\n");
 
     if(master_flash && slave_flash)
     {
@@ -402,7 +438,7 @@ uchar * combine(uchar*masterdata, int masterlength, char*_slavename, uchar*slave
 
        writer_write(&w, "FWS",3);
        headlength = (u32*)(writer_getpos(&w) + 1);
-       writer_write(&w, master.header.headerdata, master.header.headerlength);
+       writeheader(&w, master.header.headerdata, master.header.headerlength);
 
        if(config.antistream) {
            write_sprite_defines(&w);