<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>BITMAP* Comparison</title>
		<link>http://www.allegro.cc/forums/view/591706</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 11 Jun 2007 03:07:55 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Is there a way to test if two BITMAP* objects point to the same image?</p><p>ie-
</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> bmp1 <span class="k3">=</span> <a href="http://www.allegro.cc/manual/create_bitmap" target="_blank"><span class="a">create_bitmap</span></a><span class="k2">(</span><span class="n">32</span>, <span class="n">32</span><span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/clear_to_color" target="_blank"><span class="a">clear_to_color</span></a><span class="k2">(</span>bmp1, <a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><span class="k2">(</span><span class="n">0</span>,<span class="n">0</span>,<span class="n">0</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>

<a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a><span class="k3">*</span> bmp2 <span class="k3">=</span> <a href="http://www.allegro.cc/manual/create_bitmap" target="_blank"><span class="a">create_bitmap</span></a><span class="k2">(</span><span class="n">32</span>, <span class="n">32</span><span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/clear_to_color" target="_blank"><span class="a">clear_to_color</span></a><span class="k2">(</span>bmp2, <a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><span class="k2">(</span><span class="n">0</span>,<span class="n">0</span>,<span class="n">0</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>

<span class="k1">if</span> <span class="k2">(</span>bmp1 <span class="k3">=</span><span class="k3">=</span> bmp2<span class="k2">)</span> <span class="c">// they are the same image, so I want this to be true...</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jeff Bernard)</author>
		<pubDate>Sun, 03 Jun 2007 00:06:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes, by using
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">if</span> <span class="k2">(</span>bmp1 <span class="k3">=</span><span class="k3">=</span> bmp2<span class="k2">)</span>
</pre></div></div><p>
However, the code you posted will not yield that result, because those two BITMAP* objects do NOT point to the same image. They point to two different images that happen to have the same color values.</p><p>If you want to check for that, you will need some (expensive) function to check for you.</p><p>I would suggest you rethink your design if you need this function. Perhaps keep a global array of BITMAP*s and instead of checking to see if two objects have the same color info, you can just check the index of their pointer.</p><p>ie.
</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> bmpArr<span class="k2">[</span><span class="n">20</span><span class="k2">]</span><span class="k2">;</span>
...
<span class="k1">class</span> Object
<span class="k2">{</span>
private:
    <span class="k1">int</span> m_bmpIndex<span class="k2">;</span>
    ...
<span class="k2">}</span><span class="k2">;</span>
...
<span class="k1">if</span> <span class="k2">(</span>Obj1.GetGfxIndex<span class="k2">(</span><span class="k2">)</span> <span class="k3">=</span><span class="k3">=</span> Obj2.GetGfxIndex<span class="k2">(</span><span class="k2">)</span><span class="k2">)</span>
</pre></div></div><p>

A more creative solution for if you are doing a lot of putpixel-y stuff, wrap the BITMAP object in a class that puts pixel for you and adds the color value (adjusted with the x-y coordinates of where it&#39;s putting it) into a long int (maybe more memory, even) that can keep track of the value stored in a compact fashion. In effect, what you&#39;re doing here is hashing the BITMAP, so you only need to make a couple cheap integer comparisons.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Sun, 03 Jun 2007 00:12:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m trying to rip terrain sprites from a game right now. So the idea was, instead of going through each map and visually having to determine if each 16x16 tile was unique, I could just write a program that would go through each map and grab each unique tile for me.</p><p>So I suppose the only solution to this condition would be to go through and check each (or every other, every third, etc) pixel to determine if the BITMAP* objects are the same? Of course I would remove each duplication of a unique tile after having determined it&#39;s unique (in other words I wouldn&#39;t check every single tile against every single tile after the first run through checking).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jeff Bernard)</author>
		<pubDate>Sun, 03 Jun 2007 00:31:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If this is a large-scale deal, I bet there&#39;s a magical pattern-detection algorithm somewhere on Google/Wikipedia. If you just want it done, just go brute-force and _getpixel and compare everything.</p><p>Hm.</p><p>pseudocode:
</p><div class="source-code snippet"><div class="inner"><pre>make a scratch <a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a>
<span class="k1">while</span> there are tiles to get
  <span class="k1">while</span> possibilities <span class="k3">&gt;</span> <span class="n">0</span>
    get the next pixel <span class="k1">and</span> put it to the scratch <a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a>
      <span class="k1">for</span> every <a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> in possibilities
        check current pixel with same pixel from possibly-matching <a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a>
        <span class="k1">if</span> it<span class="s">'s not a match, remove possibly-matching BITMAP from possibilities</span>
<span class="s">      if we'</span>re on the last pixel, <span class="k1">and</span> there is still a <a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> in possiblities,
        we have a match, so ignore <span class="k1">this</span> tile <span class="k2">(</span>since we already have it<span class="k2">)</span>
    <span class="k1">if</span> we<span class="s">'re not ignoring this tile,</span>
<span class="s">      we have a tile that doesn'</span>t match any already in memory,
      so copy the scratch <a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> to the list of unique tiles
    re-fill possibilities with all unique tiles you<span class="s">'ve found</span>
<span class="s">  get the next tile</span>
</pre></div></div><p>

Questions?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Sun, 03 Jun 2007 00:44:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I would assign a unique hash to each tile and go from there. You might be able to just use one row or column or diagonal to build the hash. It depends on how similar the tiles are. And if that sounds like too much work, a simple brute force will get the job done.</p><p>If you post a sample bitmap, perhaps we could help determine the optimal approach.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Sun, 03 Jun 2007 00:57:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I would just go with my pseudocode, I don&#39;t think he&#39;s looking for anything high-performance. A hash would be optimal in terms of performance, but for performance vs. time spent coding, I think a brute force method that at least weeds out non-matches is good.</p><p>I guess it does depend on the tileset, though.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Sun, 03 Jun 2007 01:04:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>http://luneknight.com.ru/games/test.jpg<br />Each tile is 16x16. This image is 20x15 tiles. Most of the maps will be around this size or smaller. There&#39;s only a couple bigger, I think. Of course the tiles in this image may be a bit off from the actual thing due to saving it as a JPG.</p><p>Kibiz0r: I wrote up a quick little thing that&#39;s similar to what it says. Of course it crashes almost instantly, but if I work on it long enough I think I can work the kinks out.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jeff Bernard)</author>
		<pubDate>Sun, 03 Jun 2007 01:05:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Wow, there are a lot of repeats. Maybe you should use a hash.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Sun, 03 Jun 2007 01:07:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If you attach a lossless image (BMP or PNG) I&#39;ll try a few things with it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Sun, 03 Jun 2007 01:18:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>http://luneknight.com.ru/games/test.PNG<br />OK, here&#39;s a BMP. I originally didn&#39;t post a BMP because, well, you know the filesize on these things is huuuuuuuuge.</p><p>The check that I&#39;ve implemented (still crashes though because I can&#39;t seem to get it find the right number of unique tiles before saving them. It says there are 650 unique tiles...but crashes when it tries to save the 130th because it doesn&#39;t exist) says there are 129 unique tiles in this map. I&#39;m not sure if that&#39;s true, I guess I&#39;ll have to manually check each to see if this working properly.</p><p>EDIT-- Made the image a PNG
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jeff Bernard)</author>
		<pubDate>Sun, 03 Jun 2007 01:20:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I originally didn&#39;t post a BMP because, well, you know the filesize on these things is huuuuuuuuge.
</p></div></div><p>FYI, MS Paint saves PNG.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Sun, 03 Jun 2007 01:23:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I didn&#39;t think Paint was any good at saving PNGs. I seem to remember trying to save one before it getting a bigger filesize than BMP. Oh well, guess I&#39;m corrected here. Image editted to be a PNG.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jeff Bernard)</author>
		<pubDate>Sun, 03 Jun 2007 01:30:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
says there are 129 unique tiles in this map. I&#39;m not sure if that&#39;s true
</p></div></div><p>

That&#39;s almost half.</p><p>Actually, that might be right. I assumed all the grass was the same, but I took it into Photoshop, made a pattern from the upper-left tile and did a difference filter and it only nullified about 1/5th of the grass.</p><p>The trees also have some variation. The one-tile castles are all the same, though.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Sun, 03 Jun 2007 01:31:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Got something that works (let&#39;s just assume it does because I don&#39;t want to manually check). Even made it output the tiles into a nice little tileset (although a little disorganized and that grass is a bit too variable, making it seem like there are repeats. I may ease the test so that it might eliminate some of this that are so similar.):<br />http://luneknight.com.ru/games/set.PNG</p><p>What I did was divide the map into each tile. Then I took the first tile and compared it to the rest, comparing every other pixel. If a pixel was not the same, I aborted the test for that tile and went to the next. If the testing tile was determined to be the same as the first tile, I deleted the testing tile. I then put that first tile aside and chose the next non-eliminated tile and repeated the process.</p><p>I think that&#39;s pretty much the same as Kibiz0r&#39;s psuedo-code.</p><p>Thanks, everyone.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jeff Bernard)</author>
		<pubDate>Sun, 03 Jun 2007 02:07:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/c/e/ce0a9f3e9b87ef9b02057b7eb3c6a8b1.png" alt="592261" width="221" height="170" /></p><p>That&#39;s what my first pass came up with.</p><p>I first got all the unique colors and indexed them. (This image has 63 colors.) [edit: bad math]</p><p>My tiles are different from yours. Did you use the same image you posted? It&#39;s possible I&#39;ve got a bug somewhere...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Sun, 03 Jun 2007 02:43:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah, I used the same image.</p><p>Looking at your method, I&#39;m guessing that you added 63*pixel_number in an effort to not miss out on a unique tile because it happens to use the same colors the same amount of times as another tile. But couldn&#39;t a tile be set up in a way that it is different from another tile, but still generate the same hash? I don&#39;t really understand how the hash in generated...</p><p>What I did was first ripped EVERY tile from the image and put them into an array. Then I ran through this loop:</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="p">#define TILEW    16</span></td></tr><tr><td class="number">2</td><td><span class="p">#define NUMTESTS 16 // square-root of number of tests to run on each tile.</span></td></tr><tr><td class="number">3</td><td>&#160;</td></tr><tr><td class="number">4</td><td>std::vector<span class="k3">&lt;</span><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a><span class="k3">*</span><span class="k3">&gt;</span> unique<span class="k2">;</span></td></tr><tr><td class="number">5</td><td>unique.push_back<span class="k2">(</span>array<span class="k2">[</span><span class="n">0</span><span class="k2">]</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">6</td><td>array<span class="k2">[</span><span class="n">0</span><span class="k2">]</span> <span class="k3">=</span> NULL<span class="k2">;</span></td></tr><tr><td class="number">7</td><td>    </td></tr><tr><td class="number">8</td><td><span class="k1">int</span> deadTiles <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span></td></tr><tr><td class="number">9</td><td>&#160;</td></tr><tr><td class="number">10</td><td><span class="k1">for</span> <span class="k2">(</span><span class="k1">int</span> k <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> array<span class="k2">;</span> k<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span></td></tr><tr><td class="number">11</td><td>    <span class="k2">{</span>    </td></tr><tr><td class="number">12</td><td>       <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> height<span class="k2">;</span> i<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span></td></tr><tr><td class="number">13</td><td>          <span class="k1">for</span> <span class="k2">(</span><span class="k1">int</span> j <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> j <span class="k3">&lt;</span> width<span class="k2">;</span> j<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span></td></tr><tr><td class="number">14</td><td>             <span class="k1">if</span> <span class="k2">(</span>array<span class="k2">[</span>j<span class="k3">+</span>i<span class="k3">*</span>width<span class="k2">]</span><span class="k2">)</span></td></tr><tr><td class="number">15</td><td>             <span class="k2">{</span></td></tr><tr><td class="number">16</td><td>                <span class="k1">bool</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_519.html" target="_blank">kill</a> <span class="k3">=</span> <span class="k1">false</span><span class="k2">;</span></td></tr><tr><td class="number">17</td><td>                <span class="k1">for</span> <span class="k2">(</span><span class="k1">int</span> m <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> m <span class="k3">&lt;</span> TILEW<span class="k2">;</span> m<span class="k3">+</span><span class="k3">=</span>TILEW<span class="k3">/</span>NUMTESTS<span class="k2">)</span></td></tr><tr><td class="number">18</td><td>                <span class="k2">{</span></td></tr><tr><td class="number">19</td><td>                   <span class="k1">for</span> <span class="k2">(</span><span class="k1">int</span> n <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> n <span class="k3">&lt;</span> TILEW<span class="k2">;</span> n<span class="k3">+</span><span class="k3">=</span>TILEW<span class="k3">/</span>NUMTESTS<span class="k2">)</span></td></tr><tr><td class="number">20</td><td>                      <span class="k1">if</span> <span class="k2">(</span><a href="http://www.allegro.cc/manual/getpixel" target="_blank"><span class="a">getpixel</span></a><span class="k2">(</span>array<span class="k2">[</span>j<span class="k3">+</span>i<span class="k3">*</span>width<span class="k2">]</span>, m, n<span class="k2">)</span> <span class="k3">!</span><span class="k3">=</span> <a href="http://www.allegro.cc/manual/getpixel" target="_blank"><span class="a">getpixel</span></a><span class="k2">(</span>unique<span class="k2">[</span>unique.size<span class="k2">(</span><span class="k2">)</span><span class="k3">-</span><span class="n">1</span><span class="k2">]</span>, m, n<span class="k2">)</span><span class="k2">)</span></td></tr><tr><td class="number">21</td><td>                      <span class="k2">{</span></td></tr><tr><td class="number">22</td><td>                         <a href="http://www.delorie.com/djgpp/doc/libc/libc_519.html" target="_blank">kill</a> <span class="k3">=</span> <span class="k1">true</span><span class="k2">;</span></td></tr><tr><td class="number">23</td><td>                         <span class="k1">break</span><span class="k2">;</span></td></tr><tr><td class="number">24</td><td>                      <span class="k2">}</span></td></tr><tr><td class="number">25</td><td>                   <span class="k1">if</span> <span class="k2">(</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_519.html" target="_blank">kill</a><span class="k2">)</span></td></tr><tr><td class="number">26</td><td>                      <span class="k1">break</span><span class="k2">;</span></td></tr><tr><td class="number">27</td><td>                <span class="k2">}</span></td></tr><tr><td class="number">28</td><td>                <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_519.html" target="_blank">kill</a><span class="k2">)</span></td></tr><tr><td class="number">29</td><td>                   array<span class="k2">[</span>j<span class="k3">+</span>i<span class="k3">*</span>width<span class="k2">]</span> <span class="k3">=</span> NULL<span class="k2">;</span></td></tr><tr><td class="number">30</td><td>             <span class="k2">}</span></td></tr><tr><td class="number">31</td><td>       <span class="k1">while</span> <span class="k2">(</span><span class="k3">!</span>array<span class="k2">[</span>k<span class="k2">]</span><span class="k2">)</span></td></tr><tr><td class="number">32</td><td>       <span class="k2">{</span></td></tr><tr><td class="number">33</td><td>          k<span class="k3">+</span><span class="k3">+</span><span class="k2">;</span></td></tr><tr><td class="number">34</td><td>          <span class="k1">if</span> <span class="k2">(</span>k <span class="k3">&gt;</span><span class="k3">=</span> width<span class="k3">*</span>height<span class="k2">)</span></td></tr><tr><td class="number">35</td><td>          <span class="k2">{</span></td></tr><tr><td class="number">36</td><td>             k <span class="k3">=</span> <span class="k3">-</span><span class="n">1</span><span class="k2">;</span></td></tr><tr><td class="number">37</td><td>             <span class="k1">break</span><span class="k2">;</span></td></tr><tr><td class="number">38</td><td>          <span class="k2">}</span></td></tr><tr><td class="number">39</td><td>          deadTiles<span class="k3">+</span><span class="k3">+</span><span class="k2">;</span></td></tr><tr><td class="number">40</td><td>       <span class="k2">}</span></td></tr><tr><td class="number">41</td><td>       <span class="k1">if</span> <span class="k2">(</span>k <span class="k3">=</span><span class="k3">=</span> <span class="k3">-</span><span class="n">1</span><span class="k2">)</span></td></tr><tr><td class="number">42</td><td>          <span class="k1">break</span><span class="k2">;</span></td></tr><tr><td class="number">43</td><td>       unique.push_back<span class="k2">(</span>array<span class="k2">[</span>k<span class="k2">]</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">44</td><td>    <span class="k2">}</span></td></tr></tbody></table></div></div><p>
It&#39;s entirely possible (and I hate to say this, but probably likely) that there&#39;s a bug somewhere in my check. First off, unique.size() returns a value of 650, which is why I added the incrementation of deadTiles, so that I can just subtract that from the total of the number of tiles in the map to get the number of unique tiles so that I don&#39;t go out of bounds of the vector unique. Plus there&#39;s a lot of embedded loops which only complicate things...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jeff Bernard)</author>
		<pubDate>Sun, 03 Jun 2007 04:19:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
But couldn&#39;t a tile be set up in a way that it is different from another tile, but still generate the same hash?
</p></div></div><p>
Not if I wrote the function correctly, but now that I look at my implementation again, I don&#39;t think I did.</p><p>Edit: Duh, I wasn&#39;t considering 63<sup>256</sup>. I&#39;ll have to revise my hash. It may or may not have been giving false dupes, but it is definitely too simple as is.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Sun, 03 Jun 2007 04:32:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hash collisions are fun. <img src="http://www.allegro.cc/forums/smileys/cheesy.gif" alt=":D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Sun, 03 Jun 2007 05:13:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>After adjusting my hash function, I now get the same number of unique tiles as Jeff&#39;s brute force method. My program executes instantly, but I doubt the brute force is very slow.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Sun, 03 Jun 2007 05:26:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah, the brute force is pretty much instant. Maybe if the maps were super huge with even more unique tiles then it would be slower, but it gets the job done.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jeff Bernard)</author>
		<pubDate>Sun, 03 Jun 2007 05:43:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;d sleep easier with a brute force operation.  A missed tile would easily go unnoticed.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Tue, 05 Jun 2007 10:36:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>At least Matthew&#39;s method seems to arrange the tiles nicely...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Fladimir da Gorf)</author>
		<pubDate>Wed, 06 Jun 2007 01:18:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That&#39;s because the hash was closely associated with the color information. I used a map&lt;unsigned int, BITAMP *&gt; to store them, so they naturally came out sorted nicely. The updated hash which pretty much guarantees no false positives is much more chaotic, and as such, the tiles are random.</p><p>Of course, sorting the tiles with either the brute force method or my updated hash wouldn&#39;t be problematic. Just assign a sort id to the tile that is similar to my original hash. In this case, duplicate values wouldn&#39;t matter at all.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Wed, 06 Jun 2007 01:23:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Neil Walker has done work on this sort of thing — see his <a href="http://retrospec.sgn.net/game-overview.php?link=specmapper">Game Mapping Tool</a>. VB source is included with his download if you want to check out whatever he is doing...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Harte)</author>
		<pubDate>Wed, 06 Jun 2007 01:34:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I seem to have run into a bit of a snafu when trying to rip the tiles from a map of a different game. My method does not appear to work for another game. This time the tiles are 32x32 instead of 16x16, but that really shouldn&#39;t make a difference. <img src="http://www.allegro.cc/forums/smileys/undecided.gif" alt=":-/" /></p><p>Here&#39;s the map. 736x640, so 23x20 tiles.<br />http://allegro.cc/files/attachment/592323</p><p>When I try to rip the tiles with a brute force method, comparing all 1024 pixels of each tile, I end up with this:<br />http://allegro.cc/files/attachment/592324<br />I&#39;ve no idea where those black tiles at the end came from, nor do I know why there are so many duplicates (I&#39;ve examined the fronts of those houses and several of the wall tiles and I can&#39;t see any pixel differences). The gray tiles are just extra space from when the tiles were arranged.</p><p>So yeah...umm...help?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jeff Bernard)</author>
		<pubDate>Sat, 09 Jun 2007 10:06:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;ve attached the output of my program.</p><p>Just looking at it, it appears to have duplicate tiles though. I&#39;d have to check exact RGB values to see if they really are.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Sat, 09 Jun 2007 10:33:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I wrote a simple tile ripper a while back for my own use.  I needed a way to import old versions of worminator maps into the new build of the game, and since the tile sets had changed all the graphics were out of whack.  So, I wrote a little program that would search through the old and new tilesets to find matches, and adjust the tile numbers for the older maps so they line up correctly with the most recent tileset.</p><p>Anyway, I adapted my code quickly to search for unique tiles.  I get the same results for the first image (with 16*16 tiles), but I also get apparent &#39;duplicates&#39; when running on the latest image 2 posts back (32 *32 tiles).</p><p>After examining the image closely, there is something wrong with the tile alignment  on the latest image.  I thought the tiles were dupes initially, but after looking closely at them, they are shifted up/down/left/right by 1 pixel.  If you look carefully at the source image, some identical tiles are shifted slightly which is causing the duped tiles.  For example, look at the upper left house, and compare it to the other 4 houses with the same graphics.  If you compare them pixel by pixel, the house in the upper left is very slightly off from the rest when aligned to a 32*32 grid.</p><p>So, in this case I believe our tile rippers are working correctly, but there is something funky with the source image.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (David Layne)</author>
		<pubDate>Mon, 11 Jun 2007 00:15:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>David Layne: I noticed that as well, sometime after making that post. It turns out I ripped the map from the game incorrectly. There is a border around the playable field of the map, 31 pixels on the top, 31 pixels on the left, 33 pixels on the right, and 28 pixels on the bottom. For the image that I posted, I had removed some pixels on the bottom to get the dimensions to be correct, but I did not notice that the other borders where off on whole tiles as well.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jeff Bernard)</author>
		<pubDate>Mon, 11 Jun 2007 03:07:55 +0000</pubDate>
	</item>
</rss>
