<?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>labs.hellokeita.com &#187; BitmapData</title>
	<atom:link href="http://labs.hellokeita.com/category/bitmapdata/feed/" rel="self" type="application/rss+xml" />
	<link>http://labs.hellokeita.com</link>
	<description>Yet another labs blog</description>
	<lastBuildDate>Mon, 02 Aug 2010 11:20:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Gesture Source</title>
		<link>http://labs.hellokeita.com/2009/09/25/gesture-source/</link>
		<comments>http://labs.hellokeita.com/2009/09/25/gesture-source/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 00:33:23 +0000</pubDate>
		<dc:creator>keita</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[Flash 10]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[gesture]]></category>

		<guid isPermaLink="false">http://labs.hellokeita.com/?p=96</guid>
		<description><![CDATA[So, here is the source for the Gesture Test I posted before.
http://labs.hellokeita.com/files/gesture/gesture.zip
As I said, it&#8217;s really simple, it&#8217;s not the best code but it gives you some ideas of how it&#8217;s made.
Inside the &#8220;tags&#8221; folder, I have three pngs for each shape (triangle, square and circle).
You draw the shape you want, I trim it, and [...]]]></description>
			<content:encoded><![CDATA[<p>So, here is the source for the Gesture Test I posted before.<br />
<a href="http://labs.hellokeita.com/files/gesture/gesture.zip">http://labs.hellokeita.com/files/gesture/gesture.zip</a></p>
<p>As I said, it&#8217;s really simple, it&#8217;s not the best code but it gives you some ideas of how it&#8217;s made.</p>
<p>Inside the &#8220;tags&#8221; folder, I have three pngs for each shape (triangle, square and circle).<br />
You draw the shape you want, I trim it, and compare to each png.<br />
The comparisson is, get the drawn image, stretch it to the size of each png, and apply threshold. The BitmapData.threshold returns you an uint, the number of pixels that has been changed. With this number, divide it to the area of the png, and than, you choose the one that returns you tha smallest number.</p>
<p>and&#8230; that&#8217;s it. simple simple&#8230;</p>
<p>actually, it&#8217;s a technique used for some facial/object recognition softwares, but in a simplified way.</p>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2009/09/25/gesture-source/&ztz=Gesture Source'><img src='http://labs.hellokeita.com/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='padding:0px 5px 0px 0px;vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a> <span style='vertical-align:middle'><a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2009/09/25/gesture-source/&ztz=Gesture Source'>Vote</a></span>]]></content:encoded>
			<wfw:commentRss>http://labs.hellokeita.com/2009/09/25/gesture-source/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Gesture Test</title>
		<link>http://labs.hellokeita.com/2009/09/24/gesture-test/</link>
		<comments>http://labs.hellokeita.com/2009/09/24/gesture-test/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 00:31:13 +0000</pubDate>
		<dc:creator>keita</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[Flash 10]]></category>
		<category><![CDATA[Flash CS4]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[flash10]]></category>
		<category><![CDATA[gesture]]></category>

		<guid isPermaLink="false">http://labs.hellokeita.com/?p=93</guid>
		<description><![CDATA[Well, I went to the Flash On The Beach for the first time this year. Was really cool and inspiring.
The first night, I had some inspiration, nothing to deal to any of the presentations I saw, but just something that I wanted to test. I couldn&#8217;t upload it because I didn&#8217;t have internet at the [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I went to the Flash On The Beach for the first time this year. Was really cool and inspiring.</p>
<p>The first night, I had some inspiration, nothing to deal to any of the presentations I saw, but just something that I wanted to test. I couldn&#8217;t upload it because I didn&#8217;t have internet at the hotel, and at the venue the firewall was blocking me to connect to my FTP.</p>
<p>So, what was my experiment this time?<br />
Gesture!<br />
I think it&#8217;s working quite nice for a code I took less than an hour to write. It was much easier than I thought.</p>
<p>Just click and try to draw a Triangle, Circle or Square.<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_gesture1_486227456"
			class="flashmovie"
			width="401"
			height="431">
	<param name="movie" value="/files/gesture/gesture1.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/files/gesture/gesture1.swf"
			name="fm_gesture1_486227456"
			width="401"
			height="431">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Enjoy!<br />
I&#8217;ll post the source code later&#8230; let me take a nap now.</p>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2009/09/24/gesture-test/&ztz=Gesture Test'><img src='http://labs.hellokeita.com/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='padding:0px 5px 0px 0px;vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a> <span style='vertical-align:middle'><a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2009/09/24/gesture-test/&ztz=Gesture Test'>Vote</a></span>]]></content:encoded>
			<wfw:commentRss>http://labs.hellokeita.com/2009/09/24/gesture-test/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Remove White Background</title>
		<link>http://labs.hellokeita.com/2008/12/17/remove-white-background/</link>
		<comments>http://labs.hellokeita.com/2008/12/17/remove-white-background/#comments</comments>
		<pubDate>Tue, 16 Dec 2008 18:44:27 +0000</pubDate>
		<dc:creator>keita</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[BitmapData]]></category>

		<guid isPermaLink="false">http://labs.hellokeita.com/?p=27</guid>
		<description><![CDATA[Hi, long time that I don&#8217;t post here&#8230;
I&#8217;ve been helping Romu here at work where he was trying to use a JPG instead of a PNG with alpha channel.
Why he was trying to do that?
Firstly he was using PNGs but each image was around 600 kb. So he was trying somehow remove the white background [...]]]></description>
			<content:encoded><![CDATA[<p>Hi, long time that I don&#8217;t post here&#8230;</p>
<p>I&#8217;ve been helping <a href="http://www.soundstep.com/" target="_blank">Romu</a> here at work where he was trying to use a JPG instead of a PNG with alpha channel.<br />
Why he was trying to do that?<br />
Firstly he was using PNGs but each image was around 600 kb. So he was trying somehow remove the white background from those images because saving as JPG it&#8217;s less than 60kb.</p>
<p>It&#8217;s not a perfect background remover, but it works with the website he&#8217;s developing.</p>
<p>I don&#8217;t know if there are easier or more accurate chroma-key like background removing techniques, but&#8230; here is my workaround.</p>
<address><span style="color: #888888;">The images is not from the website&#8230; it&#8217;s a Brazilian cartoon called &#8216;A Turma da Mônica&#8217;<br />
</span></address>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_monica_362770792"
			class="flashmovie"
			width="400"
			height="621">
	<param name="movie" value="/files/whiteBackgroundRemover/monica.swf" />
	<param name="bgcolor" value="#0099CC" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/files/whiteBackgroundRemover/monica.swf"
			name="fm_monica_362770792"
			width="400"
			height="621">
		<param name="bgcolor" value="#0099CC" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Sources?<br />
Not yet&#8230; I&#8217;m busy right now but I&#8217;ll try to explain how I did it.</p>
<p>1. Using ColorMatrixFilter, I converted each RGB channel to the alpha channel.<br />
2. Using BitmapData.threshold, converted every pixel with alpha bigger than 0 to black.<br />
3. Applyed a Blur.<br />
4. Mask the original Bitmap using cacheAsBitmap = true;</p>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2008/12/17/remove-white-background/&ztz=Remove White Background'><img src='http://labs.hellokeita.com/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='padding:0px 5px 0px 0px;vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a> <span style='vertical-align:middle'><a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2008/12/17/remove-white-background/&ztz=Remove White Background'>Vote</a></span>]]></content:encoded>
			<wfw:commentRss>http://labs.hellokeita.com/2008/12/17/remove-white-background/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>My own 3d engine&#8230;</title>
		<link>http://labs.hellokeita.com/2008/02/13/my-own-3d-engine/</link>
		<comments>http://labs.hellokeita.com/2008/02/13/my-own-3d-engine/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 20:13:38 +0000</pubDate>
		<dc:creator>keita</dc:creator>
				<category><![CDATA[3d]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[Papervision3d]]></category>
		<category><![CDATA[Sandy3d]]></category>

		<guid isPermaLink="false">http://labs.hellokeita.com/2008/02/13/my-own-3d-engine/</guid>
		<description><![CDATA[Uff&#8230; long time I don&#8217;t write here&#8230;
So&#8230; what I have been doing?
Actually&#8230; nothing interesting&#8230;
Then, couple days ago I started developing my own 3d engine.
I won&#8217;t make it public because it will take all my free time that I actually don&#8217;t have&#8230;
I didn&#8217;t run any benchmarks, I think it&#8217;s more heavy processing than Papervision3d.
anyway&#8230; here is [...]]]></description>
			<content:encoded><![CDATA[<p>Uff&#8230; long time I don&#8217;t write here&#8230;</p>
<p>So&#8230; what I have been doing?<br />
Actually&#8230; nothing interesting&#8230;<br />
Then, couple days ago I started developing my own 3d engine.<br />
I won&#8217;t make it public because it will take all my free time that I actually don&#8217;t have&#8230;</p>
<p>I didn&#8217;t run any benchmarks, I think it&#8217;s more heavy processing than Papervision3d.</p>
<p>anyway&#8230; here is it&#8230;</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_20080213_281936135"
			class="flashmovie"
			width="400"
			height="300">
	<param name="movie" value="/files/k3d/20080213.swf" />
	<param name="bgcolor" value="#ffffff" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/files/k3d/20080213.swf"
			name="fm_20080213_281936135"
			width="400"
			height="300">
		<param name="bgcolor" value="#ffffff" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2008/02/13/my-own-3d-engine/&ztz=My own 3d engine...'><img src='http://labs.hellokeita.com/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='padding:0px 5px 0px 0px;vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a> <span style='vertical-align:middle'><a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2008/02/13/my-own-3d-engine/&ztz=My own 3d engine...'>Vote</a></span>]]></content:encoded>
			<wfw:commentRss>http://labs.hellokeita.com/2008/02/13/my-own-3d-engine/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Multi Gradient</title>
		<link>http://labs.hellokeita.com/2008/01/24/multi-gradient/</link>
		<comments>http://labs.hellokeita.com/2008/01/24/multi-gradient/#comments</comments>
		<pubDate>Wed, 23 Jan 2008 17:52:39 +0000</pubDate>
		<dc:creator>keita</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://labs.hellokeita.com/2008/01/24/multi-gradient/</guid>
		<description><![CDATA[
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_poliGradient_65417618"
			class="flashmovie"
			width="468"
			height="468">
	<param name="movie" value="/files/misc/poliGradient.swf" />
	<param name="bgcolor" value="#ffffff" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/files/misc/poliGradient.swf"
			name="fm_poliGradient_65417618"
			width="468"
			height="468">
		<param name="bgcolor" value="#ffffff" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
It&#8217;s a gradient created from the corners of the square.
I was googling and I found the Diamond-Square on Wikipedia.
The idea is quite simple.
First you get the top left and bottom left corner colors of the square. Than, you get the half height of the edge and also the [...]]]></description>
			<content:encoded><![CDATA[
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_poliGradient_771564145"
			class="flashmovie"
			width="468"
			height="468">
	<param name="movie" value="/files/misc/poliGradient.swf" />
	<param name="bgcolor" value="#ffffff" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/files/misc/poliGradient.swf"
			name="fm_poliGradient_771564145"
			width="468"
			height="468">
		<param name="bgcolor" value="#ffffff" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>It&#8217;s a gradient created from the corners of the square.<br />
I was googling and I found the <a href="http://en.wikipedia.org/wiki/Diamond-square_algorithm" target="_blank">Diamond-Square</a> on Wikipedia.</p>
<p>The idea is quite simple.<br />
First you get the top left and bottom left corner colors of the square. Than, you get the half height of the edge and also the average color of those colors.<br />
You repeat that until you have all pixels of the edge.</p>
<p><em>Note: The average color is not (color2 &#8211; color1) * .5.<br />
It&#8217;s (color2.r &#8211; color1.r) * .5 << 16 + (color2.g - color1.g) * .5 << 8 + (color2.b - color1.b) * .5.<br />
</em></p>
<p>After that, you make the same with the right edge.</p>
<p>Than, you do it for each edge from the top to bottom.</p>
<p>If you work around more, you can create gradient spots from any pixel you wish easily.</p>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2008/01/24/multi-gradient/&ztz=Multi Gradient'><img src='http://labs.hellokeita.com/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='padding:0px 5px 0px 0px;vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a> <span style='vertical-align:middle'><a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2008/01/24/multi-gradient/&ztz=Multi Gradient'>Vote</a></span>]]></content:encoded>
			<wfw:commentRss>http://labs.hellokeita.com/2008/01/24/multi-gradient/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Grayscale Converter</title>
		<link>http://labs.hellokeita.com/2008/01/19/grayscale-converter/</link>
		<comments>http://labs.hellokeita.com/2008/01/19/grayscale-converter/#comments</comments>
		<pubDate>Fri, 18 Jan 2008 18:00:33 +0000</pubDate>
		<dc:creator>keita</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://labs.hellokeita.com/2008/01/19/grayscale-converter/</guid>
		<description><![CDATA[Answering to CK

   1.
      ck said,
      January 14, 2008 @ 8:07 pm · Edit
      … you mentioned to use BitmapData.paletteMap() to generate a grayscale image. Until now I didn’t get this working. How did you do that?

You can [...]]]></description>
			<content:encoded><![CDATA[<p>Answering to CK</p>
<blockquote><p>
   1.<br />
      ck said,</p>
<p>      January 14, 2008 @ 8:07 pm · Edit</p>
<p>      … you mentioned to use BitmapData.paletteMap() to generate a grayscale image. Until now I didn’t get this working. How did you do that?
</p></blockquote>
<p>You can convert a BitmapData to Grayscale easily without using my ColorUtils class.<br />
[code lang="actionscript"]</p>
<p>import br.hellokeita.utils.ColorUtils;</p>
<p>...</p>
<p>var bmpData:BitmapData = new BitmapData(w, h);</p>
<p>...</p>
<p>var grayscaleArray:Array = new Array();<br />
var c:Number;<br />
for(var i = 0; i < 0xff; i++){</p>
<p>	c = i * .3 + i * .59 + i * .11;<br />
	grayscaleArray[i] = (c<<16) + (c<<8) + c;</p>
<p>}</p>
<p>bmpData.paletteMap(bmpData, bmpData.rect, new Point(0,0), grayscaleArray, grayscaleArray, grayscaleArray);<br />
[/code]</p>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2008/01/19/grayscale-converter/&ztz=Grayscale Converter'><img src='http://labs.hellokeita.com/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='padding:0px 5px 0px 0px;vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a> <span style='vertical-align:middle'><a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2008/01/19/grayscale-converter/&ztz=Grayscale Converter'>Vote</a></span>]]></content:encoded>
			<wfw:commentRss>http://labs.hellokeita.com/2008/01/19/grayscale-converter/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>BitmapData.lock benchmark</title>
		<link>http://labs.hellokeita.com/2007/12/04/bitmapdatalock-benchmark/</link>
		<comments>http://labs.hellokeita.com/2007/12/04/bitmapdatalock-benchmark/#comments</comments>
		<pubDate>Tue, 04 Dec 2007 10:22:34 +0000</pubDate>
		<dc:creator>keita</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Benchmark]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Sandy3d]]></category>

		<guid isPermaLink="false">http://labs.hellokeita.com/2007/12/04/bitmapdatalock-benchmark/</guid>
		<description><![CDATA[Well, I don&#8217;t know if anybody read the Thomas Pfeiffer aka Kiroukou (the Sandy3D creator and project leader) commented on my previous post.
Here&#8217;s what he said.
 Indeed Sandy does a clone of the original texture, for few reasons:
- avoid an unfortunate dispose call.
- allowing to have a setTransparency method to dynamically change the transparency without [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I don&#8217;t know if anybody read the Thomas Pfeiffer aka Kiroukou (the <a href="http://www.flashsandy.org/" target="_blank">Sandy3D</a> creator and project leader) commented on my <a href="http://labs.hellokeita.com/2007/11/28/bitmapmaterial-tips/#comments" target="_blank">previous post</a>.<br />
Here&#8217;s what he said.</p>
<blockquote><p> Indeed Sandy does a clone of the original texture, for few reasons:<br />
- avoid an unfortunate dispose call.<br />
- allowing to have a setTransparency method to dynamically change the transparency without changing the original bitmapdata of the user.</p>
<p>Concerning the lock() and unclock() are you sure it has a performance impact?<br />
as far I know, this can’t provide any performance boost since the bitmapdata isn’t attached to the flash display list. When the object is out of stage, there’s no advantage to lock it.<br />
But I’d be interessted to have your feedback about that, and your performance test.</p></blockquote>
<p>About the BitmapData.clone(), he got his point.<br />
It just don&#8217;t work for me because I&#8217;m using too many 3d Objects with different BitmapMaterial for each, so, the system memory gets too high.<br />
But, about the setTransparency method, he is right.</p>
<p>About the lock and unlock methods, I runned a little benchmark test, because I got curious too how much performance boost you can get.<br />
Here&#8217;s the two test I made. (Clicking on the flash area it will re-run the benchmark test)</p>
<p>Using the lock and unlock methods.<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_bitmapLockBenchmark_1986997877"
			class="flashmovie"
			width="200"
			height="30">
	<param name="movie" value="/files/benchmark/20071203/bitmapLockBenchmark.swf" />
	<param name="bgcolor" value="#f9f9f9" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/files/benchmark/20071203/bitmapLockBenchmark.swf"
			name="fm_bitmapLockBenchmark_1986997877"
			width="200"
			height="30">
		<param name="bgcolor" value="#f9f9f9" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Not using the lock and unlock methods.<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_noBitmapLockBenchmark_1742029805"
			class="flashmovie"
			width="200"
			height="30">
	<param name="movie" value="/files/benchmark/20071203/noBitmapLockBenchmark.swf" />
	<param name="bgcolor" value="#f9f9f9" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/files/benchmark/20071203/noBitmapLockBenchmark.swf"
			name="fm_noBitmapLockBenchmark_1742029805"
			width="200"
			height="30">
		<param name="bgcolor" value="#f9f9f9" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>It&#8217;s a really simple test, just to make a benchmark test.<br />
Actually, it&#8217;s not a situation that uses any 3d framework.</p>
<p>Creating a BitmapData.<br />
Creating 1000 Bitmaps.<br />
Applying 1000 times a BlurFilter over the BitmapData.</p>
<p>On my PC I get about 150ms faster with locking the BitmapData.</p>
<p>keita</p>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2007/12/04/bitmapdatalock-benchmark/&ztz=BitmapData.lock benchmark'><img src='http://labs.hellokeita.com/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='padding:0px 5px 0px 0px;vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a> <span style='vertical-align:middle'><a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2007/12/04/bitmapdatalock-benchmark/&ztz=BitmapData.lock benchmark'>Vote</a></span>]]></content:encoded>
			<wfw:commentRss>http://labs.hellokeita.com/2007/12/04/bitmapdatalock-benchmark/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>BitmapMaterial tips</title>
		<link>http://labs.hellokeita.com/2007/11/28/bitmapmaterial-tips/</link>
		<comments>http://labs.hellokeita.com/2007/11/28/bitmapmaterial-tips/#comments</comments>
		<pubDate>Wed, 28 Nov 2007 08:05:46 +0000</pubDate>
		<dc:creator>keita</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[Papervision3d]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Sandy3d]]></category>

		<guid isPermaLink="false">http://labs.hellokeita.com/2007/11/28/bitmapmaterial-tips/</guid>
		<description><![CDATA[I was making some experiments with Sandy3d and Papervision3d and I realized some tips to increase the performance.
Firstly, with Sandy3d 3.0, when you create a BitmapMaterial, the BitmapData that you used to create the Material, is cloned to create the BitmapMaterial.texture.
So, one think you can do is dispose the BitmapData that you used to create [...]]]></description>
			<content:encoded><![CDATA[<p>I was making some experiments with <a href="http://www.flashsandy.org/" target="_blank">Sandy3d</a> and <a href="http://blog.papervision3d.org" target="_blank">Papervision3d</a> and I realized some tips to increase the performance.</p>
<p>Firstly, with <a href="http://www.flashsandy.org/" target="_blank">Sandy3d</a> 3.0, when you create a BitmapMaterial, the BitmapData that you used to create the Material, is cloned to create the BitmapMaterial.texture.<br />
So, one think you can do is dispose the BitmapData that you used to create the Material after instantiating it and also, if you want to update your BitmapData use the BitmapMaterial.texture directly.</p>
<p>Something like this:<br />
[code lang="actionscript"]<br />
var bmpData:BitmapData = new BitmapData(100, 100, true, 0x00000000);<br />
var bmpMaterial:BitmapMaterial = new BitmapMaterial(bmpData);</p>
<p>bmpData.dispose();</p>
<p>bmpMaterial.texture.fillRect(new Rectangle(10,10,30,30), 0xffff0000);<br />
[/code]<br />
This will not work with Papervision3d because it uses the same BitmapData instance (in my opinion, smarter).</p>
<p>Now for both, <a href="http://www.flashsandy.org/" target="_blank">Sandy3d</a> and <a href="http://blog.papervision3d.org" target="_blank">Papervision3d</a>.<br />
As you make changes on your BitmapData, it&#8217;s updated on every poligon.<br />
So, use the BitmapData.lock() and BitmapData.unlock() when you are redrawing your BitmapData texture.</p>
<p>[code lang="actionscript"]<br />
var bmpData:BitmapData = new BitmapData(100, 100, false, 0x00000000);<br />
var bmpMaterial:BitmapMaterial = new BitmapMaterial(bmpData);</p>
<p>redrawBitmap();</p>
<p>...</p>
<p>function redrawBitmap(){</p>
<p>bmpData.lock();</p>
<p>bmpData.fillRect(bmpData.rect, 0x00000000);<br />
bmpData.fillRect(new Rectangle(10,10,30,30), 0xffff0000);</p>
<p>var blurFilter:BlurFilter = new BlurFilter(16, 16, 3);</p>
<p>bmpData.applyFilter(bmpData, bmpData.rect, new Point(0,0), blurFilter);</p>
<p>bmpData.unlock();</p>
<p>}<br />
[/code]</p>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2007/11/28/bitmapmaterial-tips/&ztz=BitmapMaterial tips'><img src='http://labs.hellokeita.com/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='padding:0px 5px 0px 0px;vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a> <span style='vertical-align:middle'><a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2007/11/28/bitmapmaterial-tips/&ztz=BitmapMaterial tips'>Vote</a></span>]]></content:encoded>
			<wfw:commentRss>http://labs.hellokeita.com/2007/11/28/bitmapmaterial-tips/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Text Highlighter &#8211; the trick</title>
		<link>http://labs.hellokeita.com/2007/11/19/text-highlighter-the-trick/</link>
		<comments>http://labs.hellokeita.com/2007/11/19/text-highlighter-the-trick/#comments</comments>
		<pubDate>Mon, 19 Nov 2007 05:21:39 +0000</pubDate>
		<dc:creator>keita</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[TextField]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://labs.hellokeita.com/2007/11/19/text-highlighter-the-trick/</guid>
		<description><![CDATA[Actually, I didn&#8217;t show the source because I wanted to know how many people was reading it, and was interested about it&#8230; so let me reveal the little trick.
First, I create a TextField, selectable(obviously) and set the alpha to zero.
Than, create a BitmapData with the TextField size, and, just draw the TextField on BitmapData each [...]]]></description>
			<content:encoded><![CDATA[<p>Actually, I didn&#8217;t show the source because I wanted to know how many people was reading it, and was interested about it&#8230; so let me reveal the little trick.</p>
<p>First, I create a TextField, selectable(obviously) and set the alpha to zero.<br />
Than, create a BitmapData with the TextField size, and, just draw the TextField on BitmapData each time the selection changes.<br />
When you draw the BitmapData, there is to ways to change the selection color, using the ColorTransform or PalleteMap methods.<br />
After that, you just place the Bitmap behind the textField.</p>
<p>[code lang="actionscript"]<br />
var color = 0xff0000;<br />
var c = ColorUtils.getRGB(color);</p>
<p>highlightBmpData.fillRect(highlightBmpData.rect, 0x00000000);<br />
highlightBmpData.draw(textField);<br />
highlightBmpData.colorTransform(highlightBmpData.rect, new ColorTransform(1, 1, 1, 1, c.r, c.g, c.b, 0));<br />
[/code]</p>
<p>One thing is that, using Color transform, you can change easily the smoothed fonts, and with PalleteMap is harder.<br />
Just remember that the selection color is always black, so you need to change the black part of the BitmapData to any color you want.</p>
<p>Easy huh?</p>
<p>PS: weird thing is that some people couldn&#8217;t see the effect on Mac with Firefox&#8230; I didn&#8217;t try it yet, but I&#8217;ll try to find a way to make it work.</p>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2007/11/19/text-highlighter-the-trick/&ztz=Text Highlighter - the trick'><img src='http://labs.hellokeita.com/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='padding:0px 5px 0px 0px;vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a> <span style='vertical-align:middle'><a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2007/11/19/text-highlighter-the-trick/&ztz=Text Highlighter - the trick'>Vote</a></span>]]></content:encoded>
			<wfw:commentRss>http://labs.hellokeita.com/2007/11/19/text-highlighter-the-trick/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>BitmapData.draw x Graphics.beginBitmapFill</title>
		<link>http://labs.hellokeita.com/2007/11/08/bitmapdatadraw-x-graphicsbeginbitmapfill/</link>
		<comments>http://labs.hellokeita.com/2007/11/08/bitmapdatadraw-x-graphicsbeginbitmapfill/#comments</comments>
		<pubDate>Wed, 07 Nov 2007 16:12:57 +0000</pubDate>
		<dc:creator>keita</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Benchmark]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://labs.hellokeita.com/2007/11/08/bitmapdatadraw-x-graphicsbeginbitmapfill/</guid>
		<description><![CDATA[Firstly&#8230; sorry for my poor English&#8230;
Working on Recyou.jp, I had to use many BitmapDatas, and so, I had to work out some way to make it lighter.
One thing I realized is that using Graphics.beginBitmapFill besides BitmapData.draw its much faster.
I made the benchmarks, drawing 10000 bitmapDatas, one using BitmapData.draw, and other using Graphics.beginBitmapFill.
First the benchmark with [...]]]></description>
			<content:encoded><![CDATA[<p>Firstly&#8230; sorry for my poor English&#8230;</p>
<p>Working on Recyou.jp, I had to use many BitmapDatas, and so, I had to work out some way to make it lighter.<br />
One thing I realized is that using Graphics.beginBitmapFill besides BitmapData.draw its much faster.</p>
<p>I made the benchmarks, drawing 10000 bitmapDatas, one using BitmapData.draw, and other using Graphics.beginBitmapFill.</p>
<p>First the benchmark with BitmapData.draw (Clicking on the flash it will re-run the benchmark):<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_b1_259689981"
			class="flashmovie"
			width="200"
			height="40">
	<param name="movie" value="/files/benchmark/20071108/b1.swf" />
	<param name="bgcolor" value="#f9f9f9" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/files/benchmark/20071108/b1.swf"
			name="fm_b1_259689981"
			width="200"
			height="40">
		<param name="bgcolor" value="#f9f9f9" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
The code is something like this:<br />
[code lang="actionscript"]<br />
var genericBmp:BitmapData = new BitmapData(100,100, false, 0x000000);<br />
var bmp:BitmapData = new BitmapData(100,100, false, 0x000000);<br />
for(var i = 0; i &lt; 10000; i++){<br />
bmp.draw(genericBmp);<br />
}<br />
[/code]</p>
<p>Now the benchmark with Graphics.beginBitmapFill (Clicking on the flash it will re-run the benchmark):<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_b2_1480261085"
			class="flashmovie"
			width="200"
			height="40">
	<param name="movie" value="/files/benchmark/20071108/b2.swf" />
	<param name="bgcolor" value="#f9f9f9" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/files/benchmark/20071108/b2.swf"
			name="fm_b2_1480261085"
			width="200"
			height="40">
		<param name="bgcolor" value="#f9f9f9" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
The code is something like this:<br />
[code lang="actionscript"]<br />
var genericBmp:BitmapData = new BitmapData(100,100, false, 0x000000);<br />
var bmp:BitmapData = new BitmapData(100,100, false, 0x000000);<br />
for(var i = 0; i &lt; 10000; i++){<br />
graphics.beginBitmapFill(genericBmp);<br />
graphics.drawRect(0,0,100,100);<br />
}<br />
[/code]</p>
<p>So, if you are trying to create some bitmap pattens or attaching a Bitmap child and redrawing it&#8217;s BitmapData, try using the Graphics.beginBitmapFill.</p>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2007/11/08/bitmapdatadraw-x-graphicsbeginbitmapfill/&ztz=BitmapData.draw x Graphics.beginBitmapFill'><img src='http://labs.hellokeita.com/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='padding:0px 5px 0px 0px;vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a> <span style='vertical-align:middle'><a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2007/11/08/bitmapdatadraw-x-graphicsbeginbitmapfill/&ztz=BitmapData.draw x Graphics.beginBitmapFill'>Vote</a></span>]]></content:encoded>
			<wfw:commentRss>http://labs.hellokeita.com/2007/11/08/bitmapdatadraw-x-graphicsbeginbitmapfill/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
