<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Combining Bitmaps</title>
		<link>http://www.allegro.cc/forums/view/610434</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sat, 16 Jun 2012 06:06:04 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Is there any way to add multiple bitmaps together to make one bitmap? </p><p>I.e have them next to each other without having to draw the same thing twice.</p><p>[image][image clone][image clone 2] etc.</p><p>I am doing this just to make my life easier when drawing a bullet tracer.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Frankincense)</author>
		<pubDate>Fri, 15 Jun 2012 15:08:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Create the large bitmap and blit the smaller ones onto it?  Which version Allegro?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Fri, 15 Jun 2012 15:12:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Allegro 5, I have no idea how to do that :/
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Frankincense)</author>
		<pubDate>Fri, 15 Jun 2012 15:48:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><a href="http://www.allegro.cc/manual/5/al_draw_bitmap">http://www.allegro.cc/manual/5/al_draw_bitmap</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Fri, 15 Jun 2012 15:57:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>you can make a function that return the bitmap combined...
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a> combineBitmaps<span class="k2">(</span><a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a> <span class="k3">*</span>a, <a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a> <span class="k3">*</span>b<span class="k2">)</span>
<span class="k2">{</span>
  <a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a> <span class="k3">*</span>bitmapCombined<span class="k2">;</span>
  <span class="c">// here the code to combine bitmaps as Arthur links suggests</span>
  <span class="k1">return</span> bitmapCombined<span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Gabriel Campos)</author>
		<pubDate>Fri, 15 Jun 2012 21:20:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>i&#39;m novice too, but it&#39;s easy to make a routine for this !</p><p>use the instruction putpixel(*bitmap,x,y) and getpixel(*bitmap,x,y) for example.</p><p>int addition_image(*BITMAP source, *BITMAP additional ,int color_transparence)<br />{ int longx=(additional-&gt;w) ; int longy=(additional-&gt;h) ;  int x,y ;<br />  for(x=0;x&lt;longx;x++)<br />   for(y=0;y&lt;longy;y++)<br />     if (getpixel(additional,x,y)!=color_transparence) <br />      if (x&lt;source-&gt;w &amp;&amp; y&lt;source-&gt;h)<br />        putpixel(source,x,y)=getpixel(additional,x,y) ;</p><p>   return 0;<br />}
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (nyergk)</author>
		<pubDate>Sat, 16 Jun 2012 05:14:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/610434/957691#target">nyergk</a> said:</div><div class="quote"><p> i&#39;m novice too, but it&#39;s easy to make a routine for this !
</p></div></div><p>Good job, you re-implemented <span class="source-code"><a href="http://www.allegro.cc/manual/draw_sprite"><span class="a">draw_sprite</span></a></span> <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />.</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/610434/957639#target">Frankincense</a> said:</div><div class="quote"><p> Is there any way to add multiple bitmaps together to make one bitmap? 
</p></div></div><p>What you should get from this thread is that there&#39;s no way easier than to draw them twice. I&#39;d suggest not combining the two bitmaps into one bitmap, but just create a function that draws those bitmaps instead of copy-pasting the two draws all over the place:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> repeat_bitmap<span class="k2">(</span><a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a><span class="k3">*</span> bmp, <span class="k1">float</span> x, <span class="k1">float</span> y, <span class="k1">size_t</span> num_x, <span class="k1">size_t</span> num_y<span class="k2">)</span>
<span class="k2">{</span>
  <span class="k1">bool</span> was_held <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_is_bitmap_drawing_held"><span class="a">al_is_bitmap_drawing_held</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
  <a href="http://www.allegro.cc/manual/al_hold_bitmap_drawing"><span class="a">al_hold_bitmap_drawing</span></a><span class="k2">(</span><span class="k1">true</span><span class="k2">)</span><span class="k2">;</span>
  <span class="k1">for</span><span class="k2">(</span><span class="k1">size_t</span> ii <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> ii <span class="k3">&lt;</span> num_y<span class="k2">;</span> ii<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span>
  <span class="k2">{</span>
    <span class="k1">for</span><span class="k2">(</span><span class="k1">size_t</span> jj <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> jj <span class="k3">&lt;</span> num_x<span class="k2">;</span> jj<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span>
    <span class="k2">{</span>
      <a href="http://www.allegro.cc/manual/al_draw_bitmap"><span class="a">al_draw_bitmap</span></a><span class="k2">(</span>bmp, x <span class="k3">+</span> jj <span class="k3">*</span> <a href="http://www.allegro.cc/manual/al_get_bitmap_width"><span class="a">al_get_bitmap_width</span></a><span class="k2">(</span>bmp<span class="k2">)</span>, y <span class="k3">+</span> ii <span class="k3">*</span> <a href="http://www.allegro.cc/manual/al_get_bitmap_height"><span class="a">al_get_bitmap_height</span></a><span class="k2">(</span>bmp<span class="k2">)</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
    <span class="k2">}</span>
  <span class="k2">}</span>
  <span class="k1">if</span><span class="k2">(</span><span class="k3">!</span>was_held<span class="k2">)</span>
    <a href="http://www.allegro.cc/manual/al_hold_bitmap_drawing"><span class="a">al_hold_bitmap_drawing</span></a><span class="k2">(</span><span class="k1">false</span><span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

The hold bitmap stuff is to make it draw faster.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Sat, 16 Jun 2012 06:06:04 +0000</pubDate>
	</item>
</rss>
