<?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>Webdevotion.be &#187; matrix</title>
	<atom:link href="http://www.webdevotion.be/blog/tag/matrix/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webdevotion.be/blog</link>
	<description>Trainer for the Flash Platform and iOS</description>
	<lastBuildDate>Tue, 01 Nov 2011 10:14:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to merge two images into one using Actionscript</title>
		<link>http://www.webdevotion.be/blog/2009/08/05/how-to-merge-two-images-into-one-in-actionscript/</link>
		<comments>http://www.webdevotion.be/blog/2009/08/05/how-to-merge-two-images-into-one-in-actionscript/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 13:18:38 +0000</pubDate>
		<dc:creator>Webdevotion</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[bitmap]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[matrix]]></category>
		<category><![CDATA[position]]></category>
		<category><![CDATA[scale]]></category>

		<guid isPermaLink="false">http://webdevotion.be/blog/?p=254</guid>
		<description><![CDATA[Well, it&#8217;s very easy, using BitmapData and Bitmap. This example makes things a bit more complex to show some principles. Hope you learn something out of it off course. // we'll scale the first ( background ) image by 50% &#8230; <a href="http://www.webdevotion.be/blog/2009/08/05/how-to-merge-two-images-into-one-in-actionscript/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Well, it&#8217;s very easy, using BitmapData and Bitmap.  This example makes things a bit more complex to show some principles.  Hope you learn something out of it off course.<br />
<code><br />
// we'll scale the first ( background ) image by 50%<br />
var s : Number = .5;</p>
<p>// create a matrix to make the scalilng of the bitmap possible<br />
var scaleMatrix : Matrix = new Matrix();</p>
<p>// apply the scaling to the matrix<br />
scaleMatrix.scale(s,s);</p>
<p>// create a bitmapdata object from an existing bitmap ( "bmp" in this case )<br />
var scaledBitmap : BitmapData = new BitmapData(bmp.width*s,bmp.height*s,false,0);</p>
<p>// draw the content and scale it using the matrix<br />
scaledBitmap.draw(bmp,scaleMatrix);</p>
<p>// we have an embedded asset called "flickr", a flickr logo in gif format<br />
var icon : Bitmap = new flickr() as Bitmap;</p>
<p>// let's place it in the bottom right corner<br />
var ix : Number = scaledBitmap.width-icon.width;<br />
var ij : Number = scaledBitmap.height-icon.height;</p>
<p>// create a matrix for the position of the icon<br />
// note the use of the ix and ij variables in the parameters<br />
var positionMatrix : Matrix = new Matrix(1,0,0,1,ix,ij);</p>
<p>// draw the icon bmp to the bitmapdata<br />
scaledBitmap.draw( icon, positionMatrix );</p>
<p>// add the new, merged, bitmap to your displaylist<br />
var bmp : Bitmap = new Bitmap( scaledBitmap );<br />
addChild( bmp );	</p>
<p>// that's it!<br />
</code></p>
<p>PS: as per user comments I&#8217;ve also uploaded an example to use in the Flash IDE ( *.fla file ) &#8211; the above example assumes you&#8217;re using Flash Builder or another editor</p>
<p>I do have to say I don&#8217;t understand why people try to merge two bitmaps in Flash using the IDE.   You could just as easily create a MovieClip with the two bitmaps on top of each other.  Or am I missing something?  Tell me in the comments!</p>
<p>Download the example *.fla file here: <a href="http://www.webdevotion.be/blog/wp-content/mergy.fla.zip">http://www.webdevotion.be/blog/wp-content/mergy.fla.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevotion.be/blog/2009/08/05/how-to-merge-two-images-into-one-in-actionscript/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

