X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fswfrender.c;h=326a18492725b950ff0974c70a5c26613a07daf8;hb=4d0534b8a840785a6ad1d9f176d445b2275d2387;hp=0547de9e06d72cfcd391ed876ddb02ec1f888cd2;hpb=de957bb4feee4d17e5349e8ccc40230bf409497e;p=swftools.git diff --git a/src/swfrender.c b/src/swfrender.c index 0547de9..326a184 100644 --- a/src/swfrender.c +++ b/src/swfrender.c @@ -10,18 +10,25 @@ #include "../lib/gfxsource.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) { @@ -31,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); @@ -51,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"); } @@ -95,7 +111,10 @@ 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(); @@ -106,6 +125,13 @@ int main(int argn, char*argv[]) } 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++) {