return head;
}
+void swf_write_header(struct writer_t*w, struct flash_header*head)
+{
+ writer_writeu8(w, head->version);
+ writer_writeu32(w, head->length);
+
+ writer_writebits(w, 31, 5);
+ writer_writebits(w, head->boundingBox.x1, 31);
+ writer_writebits(w, head->boundingBox.x2, 31);
+ writer_writebits(w, head->boundingBox.y1, 31);
+ writer_writebits(w, head->boundingBox.y2, 31);
+ writer_resetbits(w);
+ writer_writeu16(w, head->rate);
+ writer_writeu16(w, head->count);
+}
+
struct RGB readRGB()
{
struct RGB rgb;
for(t=0;t<gradient.num;t++)
{
gradient.ratios[t] = readu8();
- if(shape>=3)
+ if(shape<3)
gradient.rgb[t] = readRGB();
else
gradient.rgba[t] = readRGBA();
*pos = writer_getpos(&w);
}
-struct CXFORM readCXFORM()
+struct CXFORM readCXFORM(char alpha)
{
struct CXFORM c;
int bits;
c.hasadd=readbit();
c.hasmult=readbit();
bits=getbits(4);
- c.alpha = 0;
+ c.alpha = alpha;
if (c.hasmult)
{
obj -> matrix = readMATRIX();
obj -> hascxform = (getinputpos() < &tag->data[tag->length]);
if(obj -> hascxform)
- obj -> cxform = readCXFORM();
+ obj -> cxform = readCXFORM(0);
}
void placeobject_write (struct PlaceObject*obj, struct writer_t*w)
obj->matrix = readMATRIX();
}
if(obj->hascolortransform) {
- obj->cxform = readCXFORM();
+ obj->cxform = readCXFORM(0);
}
if(obj->hasratio) {
obj->ratio=readu16();
int getidfromtag(struct swf_tag* tag)
{
- // todo: check for more than one id
+ int num = 1;
+ switch(tag->id) {
+ case TAGID_PLACEOBJECT2:
+ num++;
+ case TAGID_PLACEOBJECT:
+ reader_init (tag->data, tag->length);
+ if(num>=2) {
+ char b = readu8();
+ if(!(b&2))
+ return -1;
+ }
+ readu16();
+ return readu16();
+ break;
+ case TAGID_REMOVEOBJECT:
+ return *(u16*)tag->data;
+ break;
+ case TAGID_REMOVEOBJECT2:
+ return -1;
+ break;
+ }
+
return *(u16*)tag->data;
}