<?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; draw()</title>
	<atom:link href="http://blog.flexexamples.com/tag/bitmapdata-draw/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>Creating FLV cuepoint thumbnails using the Bitmap and BitmapData classes</title>
		<link>http://blog.flexexamples.com/2007/08/03/creating-flv-cuepoint-thumbnails-using-the-bitmap-and-bitmapdata-classes/</link>
		<comments>http://blog.flexexamples.com/2007/08/03/creating-flv-cuepoint-thumbnails-using-the-bitmap-and-bitmapdata-classes/#comments</comments>
		<pubDate>Sat, 04 Aug 2007 05:55:06 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[Bitmap/BitmapData]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[mx:Component]]></category>
		<category><![CDATA[VideoDisplay]]></category>
		<category><![CDATA[draw()]]></category>
		<category><![CDATA[itemRenderer]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/03/creating-flv-cuepoint-thumbnails-using-the-bitmap-and-bitmapdata-classes/</guid>
		<description><![CDATA[<p>This is semi-related to the previous post, but this is something I&#8217;ve wanted to do for a while now. In fact, I first started thinking about it when I did the Image color picker sample. Basically, how can you take a bitmap image of something on the Stage and then create an item renderer out [...]]]></description>
			<content:encoded><![CDATA[<p>This is semi-related to the previous post, but this is something I&#8217;ve wanted to do for a while now. In fact, I first started thinking about it when I did the Image color picker sample. Basically, how can you take a bitmap image of something on the Stage and then create an item renderer out of it. The answer turned out to be fairly easy (much to my surprise).</p>
<p>In this mini-application we look at how to take a snapshot of the video at each cue point. We then take that bitmap, and bind it to a TileList control&#8217;s data provider so our TileList shows handy video cue points, along with an HTML-formatted label of the cue point name/time/type.</p>
<p>Full code after the jump.</p>
<p><span id="more-53"></span></p>
<p class="note">Also note that when we create the HTML-formatted itemRenderer, we have to escape the <code>&lt;b&gt;</code> tags as <code>&amp;lt;b&amp;gt;</code>.</p>
<pre class="code" lang="actionscript">
&lt;?xml version="1.0" encoding="utf-8"?&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.events.CuePointEvent;
            import mx.collections.ArrayCollection;

            [Bindable]
            private var arrColl:ArrayCollection = new ArrayCollection();

            private function copyBitmap(source:DisplayObject):Bitmap {
                var bmd:BitmapData = new BitmapData(source.width, source.height);
                bmd.draw(source);
                return new Bitmap(bmd);
            }

            private function videoDisplay_cuePoint(evt:CuePointEvent):void {
                var bm:Bitmap = copyBitmap(evt.currentTarget as DisplayObject);
                arrColl.addItem({bitmap:bm, cuePointName:evt.cuePointName, cuePointTime:evt.cuePointTime, cuePointType:evt.cuePointType});
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Panel id="panel" layout="horizontal"&gt;
        &lt;mx:HBox paddingLeft="5" paddingRight="5" paddingTop="5" paddingBottom="5" backgroundColor="black"&gt;
            &lt;mx:VideoDisplay id="videoDisplay" source="http://www.helpexamples.com/flash/video/cuepoints.flv" cuePoint="videoDisplay_cuePoint(event)" top="5" /&gt;
        &lt;/mx:HBox&gt;

        &lt;mx:TileList id="tileList" columnCount="1" dataProvider="{arrColl}" width="{videoDisplay.width}" height="{videoDisplay.height + 10}" verticalScrollPolicy="on"&gt;
            &lt;mx:itemRenderer&gt;
                &lt;mx:Component&gt;
                    &lt;mx:HBox paddingBottom="0" paddingTop="0"&gt;
                        &lt;mx:Image source="{data.bitmap}" toolTip="{data.cuePointTime}" maintainAspectRatio="true" scaleX="0.5" scaleY="0.5" /&gt;
                        &lt;mx:Text textAlign="left"&gt;
                            &lt;mx:htmlText&gt;name: &amp;lt;b&amp;gt;{data.cuePointName}&amp;lt;/b&amp;gt;&amp;lt;br /&amp;gt;time: {data.cuePointTime} &amp;lt;br /&amp;gt;type: {data.cuePointType}&lt;/mx:htmlText&gt;
                        &lt;/mx:Text&gt;
                    &lt;/mx:HBox&gt;
                &lt;/mx:Component&gt;
            &lt;/mx:itemRenderer&gt;
        &lt;/mx:TileList&gt;
    &lt;/mx:Panel&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Creating FLV cuepoint thumbnails using the Bitmap and BitmapData classes on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/08/03/creating-flv-cuepoint-thumbnails-using-the-bitmap-and-bitmapdata-classes/',contentID: 'post-53',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'draw(),itemRenderer',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/08/03/creating-flv-cuepoint-thumbnails-using-the-bitmap-and-bitmapdata-classes/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>

