X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fswf%2Fswf.c;h=0540e0f9ee924d1c4b8790fe04fbe5b0afe1a040;hp=27854cdcb5acafbcc75d3749c4a16702c7965160;hb=7d65cab745499277588a5ab47c336d218c7a7a31;hpb=6a8095cfa193eb3ed348f99ac4cd1553e0aba20b diff --git a/lib/swf/swf.c b/lib/swf/swf.c index 27854cd..0540e0f 100644 --- a/lib/swf/swf.c +++ b/lib/swf/swf.c @@ -22,6 +22,7 @@ typedef struct _swf_doc_internal int clips; SWF swf; int width,height; + MATRIX m; } swf_doc_internal_t; #define TYPE_SHAPE 1 @@ -233,14 +234,17 @@ static map16_t* extractFrame(TAG*startTag, int frame_to_extract) U16 depth = swf_GetDepth(tag); map16_remove_id(depthmap, depth); } - if(tag->id == ST_SHOWFRAME) { + if(tag->id == ST_SHOWFRAME || tag->id == ST_END) { if(frame == frame_to_extract) { return depthmap; } - frame++; - map16_enumerate(depthmap, increaseAge, 0); + if(tag->id == ST_SHOWFRAME) { + frame++; + map16_enumerate(depthmap, increaseAge, 0); + } } } + fprintf(stderr, "gfxsource_swf: frame %d not found\n", frame_to_extract); return depthmap; } @@ -250,6 +254,7 @@ typedef struct _render { map16_t*id2char; gfxdevice_t*device; + MATRIX m; int clips; } render_t; @@ -360,10 +365,10 @@ static void renderFilled(render_t*r, gfxline_t*line, FILLSTYLE*f, CXFORM*cx) RGBA swf_ColorTransform(RGBA*color, CXFORM*cx) { RGBA dest; - dest.r = (cx->r0*dest.r + cx->r1*256) >> 8; - dest.g = (cx->g0*dest.g + cx->g1*256) >> 8; - dest.b = (cx->b0*dest.b + cx->b1*256) >> 8; - dest.a = (cx->a0*dest.a + cx->a1*256) >> 8; + dest.r = (cx->r0*color->r + cx->r1*256) >> 8; + dest.g = (cx->g0*color->g + cx->g1*256) >> 8; + dest.b = (cx->b0*color->b + cx->b1*256) >> 8; + dest.a = (cx->a0*color->a + cx->a1*256) >> 8; return dest; } @@ -391,7 +396,9 @@ static void renderCharacter(render_t*r, placement_t*p, character_t*c) if(c->type == TYPE_SHAPE) { SHAPE2 shape; swf_ParseDefineShape(c->tag, &shape); - swf_ApplyMatrixToShape(&shape, &p->po.matrix); + MATRIX m; + swf_MatrixJoin(&m, &r->m, &p->po.matrix); + swf_ApplyMatrixToShape(&shape, &m); SHAPELINE*line = shape.lines; int t; for(t=1;t<=shape.numfillstyles;t++) { @@ -455,6 +462,7 @@ void swfpage_render(gfxpage_t*page, gfxdevice_t*output) r.id2char = pi->id2char; r.clips = 0; r.device = output; + r.m = pi->m; map16_enumerate(depths, placeObject, &r); } @@ -501,12 +509,12 @@ gfxpage_t* swf_doc_getpage(gfxdocument_t*doc, int page) return swf_page; } -void swf_set_parameter(char*name, char*value) +void swf_set_parameter(gfxsource_t*src, char*name, char*value) { msg(" setting parameter %s to \"%s\"", name, value); } -gfxdocument_t*swf_open(char*filename) +gfxdocument_t*swf_open(gfxsource_t*src, char*filename) { gfxdocument_t*swf_doc = (gfxdocument_t*)malloc(sizeof(gfxdocument_t)); memset(swf_doc, 0, sizeof(gfxdocument_t)); @@ -515,7 +523,6 @@ gfxdocument_t*swf_open(char*filename) TAG*tag = 0; int f; - SWF swf; int frame; render_t r; gfxdevice_t d; @@ -528,18 +535,22 @@ gfxdocument_t*swf_open(char*filename) perror("Couldn't open file: "); return 0; } - if FAILED(swf_ReadSWF(f,&swf)) { + if FAILED(swf_ReadSWF(f,&i->swf)) { fprintf(stderr, "%s is not a valid SWF file or contains errors.\n",filename); close(f); return 0; } - swf_UnFoldAll(&swf); + swf_UnFoldAll(&i->swf); + + i->id2char = extractDefinitions(&i->swf); + i->width = (i->swf.movieSize.xmax - i->swf.movieSize.xmin) / 20; + i->height = (i->swf.movieSize.ymax - i->swf.movieSize.ymin) / 20; - i->id2char = extractDefinitions(&swf); - i->width = (swf.movieSize.xmax - swf.movieSize.xmin) / 20; - i->height = (swf.movieSize.ymax - swf.movieSize.ymin) / 20; + swf_GetMatrix(0, &i->m); + i->m.tx = -i->swf.movieSize.xmin; + i->m.ty = -i->swf.movieSize.ymin; - swf_doc->num_pages = swf.frameCount; + swf_doc->num_pages = i->swf.frameCount; swf_doc->internal = i; swf_doc->get = 0; swf_doc->destroy = swf_doc_destroy;