This simple Apollo Application takes 200×150 thumbnails of a Web page.
UPDATE: See Web Snapshot – a simple Adobe AIR application
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;
html.load(new URLRequest(url));
//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;
matrix.scale(scaleX, scaleY);
snapshot.draw(htmlContent, matrix);
//3. Save as JPEG
var jpegEnc:JPEGEncoder = new JPEGEncoder(75);
var jpegData:ByteArray = jpegEnc.encode(snapshot);
var stream:FileStream = new FileStream()
stream.open(file, FileMode.WRITE);
stream.writeBytes(jpegData);
stream.close();
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.
Enjoy!
Daniel
Update:I quickly tried on Windows XP and the save doesn’t seem to work. Let me know how it works for you. Thanks.