<?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>Murtuza Topiwalla &#187; january 2010</title>
	<atom:link href="http://www.sowebme.com/murtaza/tag/january-2010/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sowebme.com/murtaza</link>
	<description>Blog about flash, movies, travel and more! Email me at yankeedoodles[at]hotmail[dot]com for anything you want to add!</description>
	<lastBuildDate>Wed, 13 Oct 2010 02:32:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Bitmap and Bitmap Data.</title>
		<link>http://www.sowebme.com/murtaza/2010/01/bitmap-and-bitmap-data/</link>
		<comments>http://www.sowebme.com/murtaza/2010/01/bitmap-and-bitmap-data/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 06:41:48 +0000</pubDate>
		<dc:creator>Murtuza</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[bitmap]]></category>
		<category><![CDATA[bitmapdata]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[january 2010]]></category>

		<guid isPermaLink="false">http://www.sowebme.com/murtaza/?p=143</guid>
		<description><![CDATA[Bitmap is a display object which wraps the BitmapData within it. The BitmapData is the array of data used to form the pixels in the image. Now a point to note here is that you can't use use the BitmapData of one state of a movieclip and expect it to gather all the frames. What it does is it takes a photograph sort of and gets its pixel data value.]]></description>
			<content:encoded><![CDATA[<p>I thought today I would post something about Bitmap and Bitmap Data in AS3.</p>
<p>Bitmap is a display object which wraps the BitmapData within it. The BitmapData is the array of data used to form the pixels in the image. Now a point to note here is that you can&#8217;t use use the BitmapData of one state of a movieclip and expect it to gather all the frames. What it does is it takes a photograph sort of and gets its pixel data value.</p>
<p>Ok so all this may seem like a lot of text. Let&#8217;s just jump into flash and figure this out. Let&#8217;s start by creating a movie clip with a text field inside of it.</p>
<p><a href="http://www.sowebme.com/murtaza/wp-content/uploads/2010/01/BitMapcopy01.jpg"><img class="alignleft size-medium wp-image-144" style="border: 0px initial initial;" title="Sample copy " src="http://www.sowebme.com/murtaza/wp-content/uploads/2010/01/BitMapcopy01-300x220.jpg" alt="sample copy" width="300" height="220" /></a>Give this movieclip an instance name of mc and hit f9 to get into the actionscript panel.</p>
<p>Now we begin by declaring our variables and defining their properties.</p>
<div id="_mcePaste"><em><span style="color: #ffff99;">var newBitmap : Bitmap;</span></em></div>
<div id="_mcePaste"><em><span style="color: #ffff99;">var bd:BitmapData=new BitmapData(mc.width,mc.height,true,0&#215;000)</span></em></div>
<div>the parameters we pass in when constructing a BitmapData are:<br />
1) width- compulsory<br />
2) height -compulsory<br />
3) alpha<br />
4) fill colour</div>
<div>We now proceed  to tell the bitmap what data to copy and then to tell the bitmap which bitmapdata it should be wrapping.</div>
<div>
<div><span style="color: #ffff99;"><em>bd.draw(mc)</em></span></div>
<div><span style="color: #ffff99;"><em>newBitmap = new Bitmap(bd);</em></span></div>
</div>
<div>we turn on smoothing for the bitmap (this is quite processor heavy for complex images but for this illustration I would like it)</div>
<div><em><span style="color: #ffff99;">newBitmap.smoothing=true;</span></em></div>
<div>finally we add it to the display list</div>
<div><span style="color: #ffff99;"><em>addChild(newBitmap);</em></span></div>
<div>lets compile and check it out</div>
<div><a href="http://www.sowebme.com/murtaza/wp-content/uploads/2010/01/BitMapcopy02.jpg"><img class="size-medium wp-image-145 alignnone" title="Bitmap Copy2" src="http://www.sowebme.com/murtaza/wp-content/uploads/2010/01/BitMapcopy02-300x158.jpg" alt="" width="300" height="158" /><br />
</a> So now obviously we have a new display object called newBitmap. This has the display object properties and methods attached to it.</div>
<div>But there is one drawback of using the Bitmap to copy movieclips you already have drawn out or text or whatever.</div>
<div>Here it is.<a href="http://www.sowebme.com/murtaza/wp-content/uploads/2010/01/BitMapcopy03.jpg"><img class="alignleft size-medium wp-image-146" title="BitMapcopy03" src="http://www.sowebme.com/murtaza/wp-content/uploads/2010/01/BitMapcopy03-299x242.jpg" alt="" width="299" height="242" /></a> The image you have just created is indeed a Bitmap. If you scale it or whatever, the image is going to be pixelated. Comparing it to vector graphics or the text you just copied, there is a noticeable difference in quality.</p>
<p>There are of course uses of this to create objects which wont ever scale. I think its really handy. Besides, this is just the first step in many more things you can do with the bitmapdata. I will try and post more about it. It is truly an amazing class. I am going to try and have another post about this in the near future.</p>
<p>Download the source here <a href="http://www.sowebme.com/murtaza/wp-content/uploads/2010/01/bitmap_data.zip">Bitmap-Data example</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.sowebme.com/murtaza/2010/01/bitmap-and-bitmap-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

