X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fswfrender.c;h=326a18492725b950ff0974c70a5c26613a07daf8;hb=4d0534b8a840785a6ad1d9f176d445b2275d2387;hp=24df1c5c841a9dcfb20d2b3638dc02b37a6ad787;hpb=2e9735ce690edb9a2fbce93d58cbe202a4eed068;p=swftools.git diff --git a/src/swfrender.c b/src/swfrender.c index 24df1c5..326a184 100644 --- a/src/swfrender.c +++ b/src/swfrender.c @@ -8,19 +8,27 @@ #include "../lib/png.h" #include "../lib/args.h" #include "../lib/gfxsource.h" -#include "../lib/swf/swf.h" +#include "../lib/readers/swf.h" +#include "../lib/devices/render.h" +#include "../lib/devices/rescale.h" static struct options_t options[] = { {"h", "help"}, {"o", "output"}, -{"n", "ng"}, +{"l", "legacy"}, {"V", "version"}, +{"X", "width"}, +{"Y", "height"}, {0,0} }; -static int ng = 0; +static int ng = 1; static char*filename = 0; static char*outputname = "output.png"; +static int quantize = 0; + +static int width = 0; +static int height = 0; int args_callback_option(char*name,char*val) { @@ -30,9 +38,18 @@ int args_callback_option(char*name,char*val) } else if(!strcmp(name, "o")) { outputname = strdup(val); return 1; - } else if(!strcmp(name, "n")) { - ng = 1; + } else if(!strcmp(name, "l")) { + ng = 0; + return 0; + } else if(!strcmp(name, "q")) { + quantize = 1; return 0; + } else if(!strcmp(name, "X")) { + width = atoi(val); + return 1; + } else if(!strcmp(name, "Y")) { + height = atoi(val); + return 1; } else { printf("Unknown option: -%s\n", name); exit(1); @@ -50,7 +67,7 @@ void args_callback_usage(char *name) printf("Usage: %s file.swf [-o output.png]\n", name); printf("\n"); printf("-h , --help Print short help message and exit\n"); - printf("-n , --ng Use next generation renderer (based on gfxdevice)\n"); + printf("-l , --legacy Use old rendering framework\n"); printf("-o , --output Output file (default: output.png)\n"); printf("\n"); } @@ -94,17 +111,27 @@ int main(int argn, char*argv[]) (swf.movieSize.ymax - swf.movieSize.ymin) / 20, 2, 1); swf_RenderSWF(&buf, &swf); RGBA* img = swf_Render(&buf); - writePNG(outputname, (unsigned char*)img, buf.width, buf.height); + if(quantize) + writePalettePNG(outputname, (unsigned char*)img, buf.width, buf.height); + else + writePNG(outputname, (unsigned char*)img, buf.width, buf.height); swf_Render_Delete(&buf); } else { gfxsource_t*src = gfxsource_swf_create(); - gfxdocument_t*doc = src->open(filename); + gfxdocument_t*doc = src->open(src, filename); if(!doc) { fprintf(stderr,"Couldn't open %s\n", filename); exit(1); } gfxdevice_t dev2,*dev=&dev2; gfxdevice_render_init(dev); + dev->setparameter(dev, "antialise", "4"); + if(quantize) { + dev->setparameter(dev, "palette", "1"); + } + if(width || height) { + dev = gfxdevice_rescale_new(dev, width, height, 0); + } int t; for(t=1;t<=doc->num_pages;t++) {