<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>OnRails.org: Web Snapshot - a simple Apollo Application.</title>
    <link>http://onrails.org/articles/2007/04/05/web-snapshot-a-simple-apollo-application</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Ruby On Rails and related matters.</description>
    <item>
      <title>Web Snapshot - a simple Apollo Application.</title>
      <description>&lt;p&gt;This simple Apollo Application takes 200&amp;#215;150 thumbnails of a Web page.&lt;/p&gt;


	&lt;p&gt;&lt;b&gt;&lt;a href="http://onrails.org/articles/2007/06/13/websnapshot-a-simple-adobe-air-application"&gt;&lt;span class="caps"&gt;UPDATE&lt;/span&gt;: See Web Snapshot &amp;#8211; a simple Adobe &lt;span class="caps"&gt;AIR&lt;/span&gt; application&lt;/a&gt;&lt;b/&gt;
&lt;div  style="overflow:hidden"&gt;
&lt;img src="http://onrails.org/files/20070404_WebSnapshot.jpg" border="0" height="268" width="586" alt="20070404_WebSnapshot.jpg" /&gt;
&lt;/div&gt;&lt;/p&gt;


	&lt;p&gt;1) Enter the &lt;span class="caps"&gt;URL&lt;/span&gt; of the page you want to &amp;#8220;Snap&amp;#8221;.
2) Click the Thumbnail 
3) A file dialog opens and asks for the File to save.&lt;/p&gt;


	&lt;p&gt;Download it now: &lt;a href="http://onrails.org/files/WebSnapshot0.1.air"&gt;WebSnapshot0.1.air&lt;/a&gt; (right click and &amp;lsquo;Download Linked File&amp;rsquo;)&lt;/p&gt;


	&lt;p&gt;It uses the new HTMLControl that Apollo provides, which behind the scene is a full fledged web browser based on &lt;span class="caps"&gt;KTHML&lt;/span&gt;. Check out an extract of the source code:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;//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(); &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;I found the JPEGEncoder &lt;a href="See http://www.kaourantin.net/2005/10/more-fun-with-image-formats-in-as3.html"&gt;here&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;And Daniel Dura had a &lt;a href="http://www.danieldura.com/archive/apollo-native-file-dialogs#more-182"&gt;trick&lt;/a&gt; to use a native save windows.&lt;/p&gt;


	&lt;p&gt;Note I need to try this application on Windows&amp;#8230;I&amp;#8217;ll do that tomorrow.&lt;/p&gt;


	&lt;p&gt;Enjoy!
Daniel&lt;/p&gt;


	&lt;p&gt;&lt;b&gt;Update:&lt;/b&gt;I quickly tried on Windows XP and the save doesn&amp;#8217;t seem to work. Let me know how it works for you. Thanks.&lt;/p&gt;


	&lt;p&gt;&lt;b&gt;&lt;a href="http://onrails.org/articles/2007/06/13/websnapshot-a-simple-adobe-air-application"&gt;&lt;span class="caps"&gt;UPDATE&lt;/span&gt;: See Web Snapshot &amp;#8211; a simple Adobe &lt;span class="caps"&gt;AIR&lt;/span&gt; application&lt;/a&gt;&lt;b/&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 05 Apr 2007 05:16:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:742b69d7-84f5-4d85-be42-ed4d52eeb197</guid>
      <author>Daniel Wanja</author>
      <link>http://onrails.org/articles/2007/04/05/web-snapshot-a-simple-apollo-application</link>
      <category>Flex</category>
    </item>
    <item>
      <title>"Web Snapshot - a simple Apollo Application." by Daniel Wanja</title>
      <description>&lt;p&gt;Not yet. But now that you&amp;#8217;ve put the pressure on, I&amp;#8217;ll have to tackle it soon;-) I need to see if the issue is in my code or if Daniel Dura&amp;#8217;s trick just doesn&amp;#8217;t work on Windows. The issue is that the current version of Apollo doesn&amp;#8217;t provide a native save file Dialog without using the trick. If I don&amp;#8217;t find a way to make the &amp;#8220;trick&amp;#8221; work on Windows, I&amp;#8217;ll create a simple custom Apollo Save File dialog. Little bit more work, but I did something similar with the RailsLogVisualizer.&lt;/p&gt;</description>
      <pubDate>Tue, 17 Apr 2007 18:40:31 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:7367c2b3-cff9-44f0-a4be-3779ed8c8493</guid>
      <link>http://onrails.org/articles/2007/04/05/web-snapshot-a-simple-apollo-application#comment-348</link>
    </item>
    <item>
      <title>"Web Snapshot - a simple Apollo Application." by Journalist</title>
      <description>&lt;p&gt;Did you make it work in Windows? I don&amp;#8217;t have any other OS :(&lt;/p&gt;</description>
      <pubDate>Tue, 17 Apr 2007 18:32:11 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:b8d7912e-f549-4295-8c56-2572f6f58fb5</guid>
      <link>http://onrails.org/articles/2007/04/05/web-snapshot-a-simple-apollo-application#comment-347</link>
    </item>
    <item>
      <title>"Web Snapshot - a simple Apollo Application." by Daniel Wanja</title>
      <description>&lt;p&gt;Thanks Sean. 
PS: wrapped the image&amp;#8230;looks better.&lt;/p&gt;</description>
      <pubDate>Tue, 10 Apr 2007 23:35:57 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:59111294-8ce5-4739-b27e-915aea779901</guid>
      <link>http://onrails.org/articles/2007/04/05/web-snapshot-a-simple-apollo-application#comment-341</link>
    </item>
    <item>
      <title>"Web Snapshot - a simple Apollo Application." by Sean Voisen</title>
      <description>&lt;p&gt;Sweet.&lt;/p&gt;


	&lt;p&gt;P.S., if you wrap that wide screenshot image in a container div with overflow: hidden, it won&amp;#8217;t screw up your sidebar :)&lt;/p&gt;</description>
      <pubDate>Tue, 10 Apr 2007 20:54:07 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:a9540abe-3a5c-443e-9d7c-25c3282c2c86</guid>
      <link>http://onrails.org/articles/2007/04/05/web-snapshot-a-simple-apollo-application#comment-340</link>
    </item>
    <item>
      <title>"Web Snapshot - a simple Apollo Application." by Daniel Wanja</title>
      <description>&lt;p&gt;I just saw that Web Snapshot was linked from &lt;a href="http://labs.adobe.com/wiki/index.php/Apollo:Applications"&gt;Apollo:Applications&lt;/a&gt; page. There I saw that I wasn&amp;#8217;t first to the game, there is another similar application &lt;a href="http://blog.everythingflex.com/2007/03/19/grabit-html-within-apollo"&gt;Grabit&lt;/a&gt; that&amp;#8217;s looks pretty good.&lt;/p&gt;</description>
      <pubDate>Thu, 05 Apr 2007 15:52:35 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:cbf4f1e7-2390-4730-945b-c882fc6beb22</guid>
      <link>http://onrails.org/articles/2007/04/05/web-snapshot-a-simple-apollo-application#comment-337</link>
    </item>
    <item>
      <title>"Web Snapshot - a simple Apollo Application." by Daniel Wanja</title>
      <description>&lt;p&gt;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.&lt;/p&gt;</description>
      <pubDate>Thu, 05 Apr 2007 14:09:25 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:81c77b7e-eb2d-4465-a250-b8f68ad943fe</guid>
      <link>http://onrails.org/articles/2007/04/05/web-snapshot-a-simple-apollo-application#comment-335</link>
    </item>
    <item>
      <title>"Web Snapshot - a simple Apollo Application." by Lee</title>
      <description>&lt;p&gt;Very cool!  When can I use it on Linux? :)&lt;/p&gt;</description>
      <pubDate>Thu, 05 Apr 2007 07:04:44 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:67fe6a0d-0093-468e-bd56-029990d3acd8</guid>
      <link>http://onrails.org/articles/2007/04/05/web-snapshot-a-simple-apollo-application#comment-333</link>
    </item>
  </channel>
</rss>
