This simple Apollo Application takes 200×150 thumbnails of a Web page.
1) Enter the URL of the page you want to “Snap”.
2) Click the Thumbnail
3) A file dialog opens and asks for the File to save.
Download it now: WebSnapshot0.1.air (right click and ‘Download Linked File’)
It uses the new HTMLControl that Apollo provides, which behind the scene is a full fledged web browser based on KTHML. Check out an extract of the source code:
//1. Load the page (asynchronously)
var html:HTMLControl = new HTMLControl();
html.width = 400;
html.height = 300;
//2. Draw and scale the rendered html into a bitmap
var snapshot:BitmapData = new BitmapData(200, 150);
var matrix:Matrix = new Matrix();
var scaleX:Number = 0.5;
var scaleY:Number = 0.5;
//3. Save as JPEG
var jpegEnc:JPEGEncoder = new JPEGEncoder(75);
var jpegData:ByteArray = jpegEnc.encode(snapshot);
var stream:FileStream = new FileStream()
I found the JPEGEncoder here.
And Daniel Dura had a trick to use a native save windows.
Note I need to try this application on Windows…I’ll do that tomorrow.
Update:I quickly tried on Windows XP and the save doesn’t seem to work. Let me know how it works for you. Thanks.