X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;ds=inline;f=src%2Fswfc.c;h=2c23d95cd065b803a23ccc5e6cca6b247680a08d;hb=6955bfe4fd7cd92489d8f8be792bb232f35768bd;hp=3a2f7ed29db67f21a91123d4f0e48fd6bceda05b;hpb=6e9435d4bcafbe6aac9c04ede599cc4d564c4241;p=swftools.git diff --git a/src/swfc.c b/src/swfc.c index 3a2f7ed..2c23d95 100644 --- a/src/swfc.c +++ b/src/swfc.c @@ -642,8 +642,11 @@ static void s_endSWF() swf = stack[stackpos].swf; filename = stack[stackpos].filename; - + + //if(tag->prev && tag->prev->id != ST_SHOWFRAME) + // tag = swf_InsertTag(tag, ST_SHOWFRAME); tag = swf_InsertTag(tag, ST_SHOWFRAME); + tag = swf_InsertTag(tag, ST_END); swf_OptimizeTagOrder(swf); @@ -699,7 +702,7 @@ void s_close() int s_getframe() { - return currentframe; + return currentframe+1; } void s_frame(int nr, int cut, char*name) @@ -707,13 +710,9 @@ void s_frame(int nr, int cut, char*name) int t; TAG*now = tag; - /* // enabling the following code will make the frame - handling much more intuitive, but also break old - code: - - if(nr<1) - syntaxerror("Frame number need to be at least 1"); - nr--;*/ + if(nr<1) + syntaxerror("Illegal frame number"); + nr--; // internally, frame 1 is frame 0 for(t=currentframe;tfillstyle0 > s2.numfillstyles) line->fillstyle0 = 0; + if(line->fillstyle1 > s2.numfillstyles) line->fillstyle1 = 0; + if(line->linestyle > s2.numlinestyles) line->linestyle = 0; + line = line->next; + } + + swf_Shape2ToShape(&s2,&s); + + free(s2.fillstyles); + free(s2.linestyles); + free(s.fillstyle.data); + free(s.linestyle.data); + *destdata = s.data; + *destbitlen = s.bitlen; +} + void s_filled(char*name, char*outlinename, RGBA color, int linewidth, char*texture) { SRECT rect,r2; @@ -834,11 +864,11 @@ void s_filled(char*name, char*outlinename, RGBA color, int linewidth, char*textu tag = swf_InsertTag(tag, ST_DEFINESHAPE3); swf_ShapeNew(&s); - ls1 = swf_ShapeAddLineStyle(s,linewidth,&color); + if(linewidth) + ls1 = swf_ShapeAddLineStyle(s,linewidth,&color); if(texture) fs1 = addFillStyle(s, &r2, texture); - else - syntaxerror("non filled outlines not yet supported- please supply a fill= argument"); + swf_SetU16(tag,id); rect.xmin = r2.xmin-linewidth-linewidth/2; rect.ymin = r2.ymin-linewidth-linewidth/2; @@ -847,8 +877,11 @@ void s_filled(char*name, char*outlinename, RGBA color, int linewidth, char*textu swf_SetRect(tag,&rect); swf_SetShapeStyles(tag, s); - swf_SetShapeBits(tag, outline->shape); //does not count bits! - swf_SetBlock(tag, outline->shape->data, (outline->shape->bitlen+7)/8); + swf_ShapeCountBits(s,0,0); + swf_RecodeShapeData(outline->shape->data, outline->shape->bitlen, 1, 1, + &s->data, &s->bitlen, s->bits.fill, s->bits.line); + swf_SetShapeBits(tag, s); + swf_SetBlock(tag, s->data, (s->bitlen+7)/8); swf_ShapeFree(s); s_addcharacter(name, id, tag, rect); @@ -859,14 +892,15 @@ void s_circle(char*name, int r, RGBA color, int linewidth, char*texture) { SRECT rect,r2; SHAPE* s; - int ls1,fs1=0; + int ls1=0,fs1=0; r2.xmin = r2.ymin = 0; r2.xmax = 2*r; r2.ymax = 2*r; tag = swf_InsertTag(tag, ST_DEFINESHAPE3); swf_ShapeNew(&s); - ls1 = swf_ShapeAddLineStyle(s,linewidth,&color); + if(linewidth) + ls1 = swf_ShapeAddLineStyle(s,linewidth,&color); if(texture) fs1 = addFillStyle(s, &r2, texture); swf_SetU16(tag,id); @@ -1242,14 +1276,10 @@ void s_outline(char*name, char*format, char*source) draw_string(&draw, source); draw.finish(&draw); shape = swf_ShapeDrawerToShape(&draw); - //shape2 = swf_ShapeToShape2(shape); - //bounds = swf_GetShapeBoundingBox(shape2); - //swf_Shape2Free(shape2); bounds = swf_ShapeDrawerGetBBox(&draw); draw.dealloc(&draw); - outline = (outline_t*)malloc(sizeof(outline_t)); - memset(outline, 0, sizeof(outline_t)); + outline = (outline_t*)rfx_calloc(sizeof(outline_t)); outline->shape = shape; outline->bbox = bounds; @@ -2230,7 +2260,7 @@ static int c_frame(map_t*args) else { frame = parseInt(framestr); if(s_getframe() >= frame - && !(frame==0 && s_getframe()==frame)) // equality is o.k. for frame 0 + && !(frame==1 && s_getframe()==frame)) // equality is o.k. for frame 0 syntaxerror("frame expression must be >%d (is:%s)", s_getframe(), framestr); } s_frame(frame, cut, name);