<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>how to divide a gif image into pieces</title>
		<link>http://www.allegro.cc/forums/view/588196</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 24 Oct 2006 10:51:43 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>hi all,</p><p>          I want to divide a gif image with 4*4(16), 3*3(9),etc parts.</p><p>          Thank you
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (raja peter)</author>
		<pubDate>Tue, 24 Oct 2006 10:03:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Be more specific.</p><p>I&#39;m guessing you want tiles... I&#39;m also having to assume you are already using a library that can load gifs into Allegro, and that you want to divide the image into diffrent parts inside of your program (as opposed to storing them as a file/files.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Ceagon Xylas)</author>
		<pubDate>Tue, 24 Oct 2006 10:18:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>exactly ceagon</p><p>    I used algif library and load_gif() fn. i want to divide that image into a no of pieces which on the whole constitute the original image.<br /> <br />    Thank You
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (raja peter)</author>
		<pubDate>Tue, 24 Oct 2006 10:33:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Okay, first off, you&#39;re going to need an array of bitmaps. You can then store each tile to its individual bitmap.
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>tile<span class="k2">[</span><span class="n">64</span><span class="k2">]</span><span class="k2">;</span>
<span class="k1">for</span><span class="k2">(</span><span class="k1">int</span> i<span class="k3">=</span><span class="n">0</span><span class="k2">;</span> i<span class="k3">&lt;</span><span class="n">64</span><span class="k2">;</span> i<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span>
  tile<span class="k3">&lt;</span>i&gt;<span class="k3">=</span><span class="n">0</span><span class="k2">;</span>
</pre></div></div><p>
Then you have to decide how you want to rip the segments of the image to the bitmaps themselves. I rip them in a row going left to right. Like this: <img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/6/1/6141bfb16d7741d513e437d5b2505bd1.gif" alt="image1vy6.gif" width="64" height="16" />
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>g<span class="k3">=</span>load_gif<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="k1">const</span> <span class="k1">int</span> tile_width<span class="k3">=</span><span class="n">16</span><span class="k2">;</span>
<span class="k1">const</span> <span class="k1">int</span> tile_height<span class="k3">=</span><span class="n">16</span><span class="k2">;</span> 
<span class="k1">for</span><span class="k2">(</span><span class="k1">int</span> i<span class="k3">=</span><span class="n">0</span><span class="k2">;</span> i<span class="k3">&lt;</span>g-&gt;w<span class="k3">/</span>tile_width<span class="k2">;</span> i<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span> <span class="c">//decides how many tiles it can squeeze out of the bitmap</span>
  tile<span class="k3">&lt;</span>i&gt;<span class="k3">=</span><a href="http://www.allegro.cc/manual/create_sub_bitmap" target="_blank"><span class="a">create_sub_bitmap</span></a><span class="k2">(</span>g,i<span class="k3">*</span>tile_width,<span class="n">0</span>,tile_width,tile_height<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
So now the blue tile (tile 0 in the image) is stored in tile[0].</p><p>I&#39;ll warn you, I didn&#39;t compile any of that. So there may be some errors. But this is the theory behind it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Ceagon Xylas)</author>
		<pubDate>Tue, 24 Oct 2006 10:44:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>thanks
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (raja peter)</author>
		<pubDate>Tue, 24 Oct 2006 10:51:43 +0000</pubDate>
	</item>
</rss>
