<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flex Examples &#187; captureBitmapData()</title>
	<atom:link href="http://blog.flexexamples.com/tag/capturebitmapdata/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Wed, 26 Jan 2011 18:09:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Taking screenshots in Flex 3 using the ImageSnapshot.captureBitmapData() method</title>
		<link>http://blog.flexexamples.com/2007/11/17/taking-screenshots-in-flex-3-using-the-imagesnapshotcapturebitmapdata-method/</link>
		<comments>http://blog.flexexamples.com/2007/11/17/taking-screenshots-in-flex-3-using-the-imagesnapshotcapturebitmapdata-method/#comments</comments>
		<pubDate>Sun, 18 Nov 2007 06:41:04 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Bitmap/BitmapData]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[ImageSnapshot]]></category>
		<category><![CDATA[captureBitmapData()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/11/17/taking-screenshots-in-flex-3-using-the-imagesnapshotcapturebitmapdata-method/</guid>
		<description><![CDATA[<p>As we saw in a previous entry, <a href="http://blog.flexexamples.com/2007/11/16/taking-screenshots-in-flex-using-the-imagesnapshotcaptureimage-method/">&#8220;Taking screenshots in Flex 3 using the ImageSnapshot.captureImage() method&#8221;</a>, it is possible to take a screenshot of an item on the display list using the static ImageCapture.captureImage() method. Once the image is captured, we accessed the image&#8217;s pixel data using the ImageCapture object&#8217;s data property, which was [...]]]></description>
			<content:encoded><![CDATA[<p>As we saw in a previous entry, <a href="http://blog.flexexamples.com/2007/11/16/taking-screenshots-in-flex-using-the-imagesnapshotcaptureimage-method/">&#8220;Taking screenshots in Flex 3 using the ImageSnapshot.captureImage() method&#8221;</a>, it is possible to take a screenshot of an item on the display list using the static <code>ImageCapture.captureImage()</code> method. Once the image is captured, we accessed the image&#8217;s pixel data using the ImageCapture object&#8217;s <code>data</code> property, which was displayed using the SWFLoader control.</p>
<p class="alert">The ability to load a ByteArray object directly into a SWFLoader was added in Flex 3 build 187814, you may need to update your SDK build by downloading a recent nightly build from <a href="http://labs.adobe.com/technologies/flex/sdk/flex3sdk.html">http://labs.adobe.com/technologies/flex/sdk/flex3sdk.html</a>.</p>
<p>The following example shows how you can take a snapshot of an item on the display list using the static <code>ImageSnapshot.captureBitmapData()</code> method, which returns a BitmapData object, as seen in the following snippet:</p>
<pre class="code">
var imageBitmapData:BitmapData = ImageSnapshot.captureBitmapData(source);
swfLoader.source = new Bitmap(imageBitmapData);
</pre>
<p>Full code after the jump.</p>
<p><span id="more-308"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/ImageSnapshot_captureBitmapData_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/11/17/taking-screenshots-in-flex-3-using-the-imagesnapshotcapturebitmapdata-method/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.graphics.ImageSnapshot;

            private function takeSnapshot(source:IBitmapDrawable):void {
                var imageBitmapData:BitmapData = ImageSnapshot.captureBitmapData(source);
                swfLoader.source = new Bitmap(imageBitmapData);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Array id="arr"&gt;
        &lt;mx:Object col1="Row 1, Col 1" col2="Row 1, Col 2" /&gt;
        &lt;mx:Object col1="Row 2, Col 1" col2="Row 2, Col 2" /&gt;
        &lt;mx:Object col1="Row 3, Col 1" col2="Row 3, Col 2" /&gt;
        &lt;mx:Object col1="Row 4, Col 1" col2="Row 4, Col 2" /&gt;
        &lt;mx:Object col1="Row 5, Col 1" col2="Row 5, Col 2" /&gt;
        &lt;mx:Object col1="Row 6, Col 1" col2="Row 6, Col 2" /&gt;
    &lt;/mx:Array&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Button label="Take snapshot of DataGrid"
                click="takeSnapshot(dataGrid);" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:HBox&gt;
        &lt;mx:DataGrid id="dataGrid" dataProvider="{arr}" /&gt;
        &lt;mx:SWFLoader id="swfLoader"&gt;
            &lt;mx:filters&gt;
                &lt;mx:DropShadowFilter /&gt;
            &lt;/mx:filters&gt;
        &lt;/mx:SWFLoader&gt;
    &lt;/mx:HBox&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/ImageSnapshot_captureBitmapData_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/ImageSnapshot_captureBitmapData_test/bin/main.html" width="100%" height="300"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Taking screenshots in Flex 3 using the ImageSnapshot.captureBitmapData() method on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/11/17/taking-screenshots-in-flex-3-using-the-imagesnapshotcapturebitmapdata-method/',contentID: 'post-308',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'captureBitmapData()',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2007/11/17/taking-screenshots-in-flex-3-using-the-imagesnapshotcapturebitmapdata-method/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

