7 #include "../lib/rfxswf.h"
8 #include "../lib/png.h"
9 #include "../lib/args.h"
11 static struct options_t options[] = {
18 static char*filename = 0;
19 static char*outputname = "output.png";
21 int args_callback_option(char*name,char*val)
23 if(!strcmp(name, "V")) {
24 printf("swfrender - part of %s %s\n", PACKAGE, VERSION);
26 } else if(!strcmp(name, "o")) {
27 outputname = strdup(val);
30 printf("Unknown option: -%s\n", name);
36 int args_callback_longoption(char*name,char*val)
38 return args_long2shortoption(options, name, val);
40 void args_callback_usage(char *name)
43 printf("Usage: %s file.swf [-o output.png]\n", name);
45 printf("-h , --help Print short help message and exit\n");
46 printf("-o , --output Output file (default: output.png)\n");
49 int args_callback_command(char*name,char*val)
52 fprintf(stderr, "Only one file allowed. You supplied at least two. (%s and %s)\n",
61 int main(int argn, char*argv[])
66 processargs(argn, argv);
69 fprintf(stderr, "You must supply a filename.\n");
73 fi = open(filename, O_RDONLY|O_BINARY);
75 fprintf(stderr,"Couldn't open %s\n", filename);
80 if(swf_ReadSWF(fi,&swf)<0) {
81 fprintf(stderr,"%s is not a valid SWF file or contains errors.\n",argv[1]);
86 swf_Render_Init(&buf, 0,0, (swf.movieSize.xmax - swf.movieSize.xmin) / 20,
87 (swf.movieSize.ymax - swf.movieSize.ymin) / 20, 2, 1);
89 swf_RenderSWF(&buf, &swf);
91 RGBA* img = swf_Render(&buf);
93 writePNG(outputname, (unsigned char*)img, buf.width, buf.height);
95 swf_Render_Delete(&buf);