X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fswfrender.c;h=9362fded585fb103d395e80d4efc935d6abd4d8c;hb=f9dce1cb6c3810ff91601016ae3cba172ca7f903;hp=0547de9e06d72cfcd391ed876ddb02ec1f888cd2;hpb=de957bb4feee4d17e5349e8ccc40230bf409497e;p=swftools.git diff --git a/src/swfrender.c b/src/swfrender.c index 0547de9..9362fde 100644 --- a/src/swfrender.c +++ b/src/swfrender.c @@ -14,14 +14,20 @@ 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 +37,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 +66,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 +110,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 +124,12 @@ int main(int argn, char*argv[]) } gfxdevice_t dev2,*dev=&dev2; gfxdevice_render_init(dev); + 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++) {