how to save a zoomed-in copy of a swf file
I have a swf page that I would like to convert to a png file. Before I convert the file, I would like to zoom in to the swf file so that I have a larger image. I try swftools to convert, but the png image quality is not good enough: Zoomed-in png image looks too blurry.
What do you suggest I should do to capture/use a zoome开发者_运维问答d-in version of a swf file. A linux compatible command line tool would be great as I am thinking of converting hundreds of images.
Thanks a lot
It's not a linux way, but I can't imagine nothing else.
My solution is to write AIR application, which loads swf file, adds it to its screen, makes a "prinscreen" and saves the printscreen to the png.
1) every display object can be drawn on BitmapData
with additional transforming control (you need scaling), e.g.:
var btn:Button = new Button;
var bitmap:BitmapData = new BitmapData(width, height);
var m:Matrix = new Matrix;
m.scale(2, 2);
bitmap.draw(btn, m);
More on this: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html#draw%28%29
2) BitmapData
can be converted to png and saved. To convert you can use built-in PNGEncoder
. The output BiteArray
can be saved to specified file:
var bitmap:BitmapData = makeScreenShot();
var encoder:PNGEncoder = new PNGEncoder();
var bytes:ByteArray = encoder.encode(bitmap);
var imgStream:FileStream = new FileStream();
var img:File = new File(path);
imgStream.open(img, FileMode.WRITE);
imgStream.writeBytes(bytes);
imgStream.close();
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/FileStream.html
Additionaly, as PNGEncoder is slow, you can write your own using Alchemy, since pnglib is ported (it is in sdk examples).
3) You can pass pathes to swfs to AIR app in command line arguments:
<mx:WindowedApplication
xmlns:mx="http://www.adobe.com/2006/mxml"
invoke="onInvoke(event)">
...
private function onInvoke(event:InvokeEvent):void
{
for each (str:String in event.arguments)
//do something
}
http://cookbooks.adobe.com/post_How_do_I_use_command_line_arguments_with_my_AIR_ap-8003.html
精彩评论