Web Snapshot - a simple Apollo Application. 7
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.
Very cool! When can I use it on Linux? :)
Apollo will be supported on Linux but I believe only once Adobe releases version 1. Currently there is an Apollo run time for Windows and OSX.
I just saw that Web Snapshot was linked from Apollo:Applications page. There I saw that I wasn’t first to the game, there is another similar application Grabit that’s looks pretty good.
Sweet.
P.S., if you wrap that wide screenshot image in a container div with overflow: hidden, it won’t screw up your sidebar :)
Thanks Sean. PS: wrapped the image…looks better.
Did you make it work in Windows? I don’t have any other OS :(
Not yet. But now that you’ve put the pressure on, I’ll have to tackle it soon;-) I need to see if the issue is in my code or if Daniel Dura’s trick just doesn’t work on Windows. The issue is that the current version of Apollo doesn’t provide a native save file Dialog without using the trick. If I don’t find a way to make the “trick” work on Windows, I’ll create a simple custom Apollo Save File dialog. Little bit more work, but I did something similar with the RailsLogVisualizer.