- if(swf_ReadSWF(fi,&swf)<0) {
- fprintf(stderr,"%s is not a valid SWF file or contains errors.\n",argv[1]);
- close(fi);
- }
+ if(!ng) {
+ fi = open(filename, O_RDONLY|O_BINARY);
+ if (fi<=0) {
+ fprintf(stderr,"Couldn't open %s\n", filename);
+ perror(argv[1]);
+ exit(1);
+ }
+ if(swf_ReadSWF(fi,&swf)<0) {
+ fprintf(stderr,"%s is not a valid SWF file or contains errors.\n",argv[1]);
+ close(fi);
+ }
+ RENDERBUF buf;
+ swf_Render_Init(&buf, 0,0, (swf.movieSize.xmax - swf.movieSize.xmin) / 20,
+ (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);
+ swf_Render_Delete(&buf);
+ } else {
+ gfxsource_t*src = gfxsource_swf_create();
+ 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);