<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Is this me or Allegro?!?</title>
		<link>http://www.allegro.cc/forums/view/615293</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Wed, 15 Apr 2015 21:19:51 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m trying to scale images to a temp buffer and then draw that image to the screen. The base image is a huge image of sprites that are 16x32. I&#39;m using the following code to draw the individual sprites, but the destination is not correct and seems to be based on the scale factor. I&#39;m sure I&#39;m just missing something stupid but can&#39;t seem to see it at the moment. Any help would be appreciated. I&#39;m using allegro-5.0.10 if that helps at all...
</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span><span class="k1">bool</span> DrawTerrainImage<span class="k2">(</span> <a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a> <span class="k3">*</span>terrainImage, <span class="k1">float</span> x, <span class="k1">float</span> y,
<span class="number">  2</span>             <span class="k1">int</span> terrainID, <span class="k1">unsigned</span> <span class="k1">char</span> scaleFactor <span class="k2">)</span>
<span class="number">  3</span><span class="k2">{</span>
<span class="number">  4</span>  <span class="c">// TODO: add bounds handlers for known end points.</span>
<span class="number">  5</span>  <span class="k1">int</span> dw <span class="k3">=</span> <span class="n">16</span><span class="k3">*</span>scaleFactor<span class="k2">;</span>
<span class="number">  6</span>  <span class="k1">int</span> dh <span class="k3">=</span> <span class="n">32</span><span class="k3">*</span>scaleFactor<span class="k2">;</span>
<span class="number">  7</span>  <a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a> <span class="k3">*</span>temp <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_create_bitmap"><span class="a">al_create_bitmap</span></a><span class="k2">(</span>dw,dh<span class="k2">)</span><span class="k2">;</span>
<span class="number">  8</span>  <span class="k1">if</span> <span class="k2">(</span> <span class="k3">!</span>temp <span class="k2">)</span>
<span class="number">  9</span>    <span class="k1">return</span> <span class="k1">false</span><span class="k2">;</span>
<span class="number"> 10</span>  <a href="http://www.allegro.cc/manual/ALLEGRO_STATE"><span class="a">ALLEGRO_STATE</span></a> state<span class="k2">;</span>
<span class="number"> 11</span>  <a href="http://www.allegro.cc/manual/al_store_state"><span class="a">al_store_state</span></a><span class="k2">(</span><span class="k3">&amp;</span>state,ALLEGRO_STATE_TARGET_BITMAP<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 12</span>  <a href="http://www.allegro.cc/manual/al_set_target_bitmap"><span class="a">al_set_target_bitmap</span></a><span class="k2">(</span>temp<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 13</span>  <span class="c">//                    image,       sx,           sy, sw, sh, dx, dy,dw,dh, flags</span>
<span class="number"> 14</span>  <a href="http://www.allegro.cc/manual/al_draw_scaled_bitmap"><span class="a">al_draw_scaled_bitmap</span></a><span class="k2">(</span>terrainImage,<span class="n">16</span><span class="k3">*</span>terrainID, <span class="n">0</span>,  <span class="n">16</span>, <span class="n">32</span>, <span class="n">0</span>,  <span class="n">0</span>, dw, dh,<span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 15</span>  <a href="http://www.allegro.cc/manual/al_restore_state"><span class="a">al_restore_state</span></a><span class="k2">(</span><span class="k3">&amp;</span>state<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 16</span>  <a href="http://www.allegro.cc/manual/al_draw_bitmap"><span class="a">al_draw_bitmap</span></a><span class="k2">(</span>temp,x,y,<span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 17</span>  <a href="http://www.allegro.cc/manual/al_destroy_bitmap"><span class="a">al_destroy_bitmap</span></a><span class="k2">(</span>temp<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 18</span>  temp <span class="k3">=</span> NULL<span class="k2">;</span>
<span class="number"> 19</span>  <span class="k1">return</span> <span class="k1">true</span><span class="k2">;</span>
<span class="number"> 20</span><span class="k2">}</span>
<span class="number"> 21</span><span class="c">///////////////////////////////////////////////////////////////////////////////</span>
</div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Don Freeman)</author>
		<pubDate>Wed, 15 Apr 2015 11:50:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Does this compute??</p><p>unsigned char scaleFactor </p><p>// I think the char should at least be converted to int or double</p><p>int dw = 16*scaleFactor;
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (#00JMP00)</author>
		<pubDate>Wed, 15 Apr 2015 14:09:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Why? Could you imagine a case where you&#39;d want to scale a 16x32 pixel sprite more than 255 times!?<br />Edit:<br />As an example, here is the command to draw and then the output...
</p><div class="source-code snippet"><div class="inner"><pre>   DrawTerrainImage<span class="k2">(</span>terrain,<span class="n">10</span>,<span class="n">10</span>,<span class="n">5</span>,<span class="n">10</span><span class="k2">)</span><span class="k2">;</span>
   DrawTerrainImage<span class="k2">(</span>terrain,<span class="n">200</span>,<span class="n">200</span>,<span class="n">16</span>,<span class="n">5</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
<span class="remote-thumbnail"><span class="json">{"name":"609380","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/1\/d1fb89476a9b8f2e340ca30bbf83da14.jpg","w":400,"h":400,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/1\/d1fb89476a9b8f2e340ca30bbf83da14"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/d/1/d1fb89476a9b8f2e340ca30bbf83da14-240.jpg" alt="609380" width="240" height="240" /></span></p><p>Edit:<br />Nevermind. <img src="http://www.allegro.cc/forums/smileys/rolleyes.gif" alt="::)" /> I feel dumb hahaha. I forgot that half y of the image is transparent on most of the sprites, so it just looked off by that much. I&#39;ll probably store these all in a structure during loading so I don&#39;t have to do stretching every draw cycle. Thanks all.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Don Freeman)</author>
		<pubDate>Wed, 15 Apr 2015 20:03:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>For one, I would do some input validation to be sure the problem is actually located in your function.</p><p>Is this C or C++?</p><p>I would check to verify in a debugger or with printf, that the values you&#39;re giving are all correct before they hit an Allegro function.</p><p>Then, I&#39;d make sure all of my Allegro/OpenGL transformations are set up correctly. Actually, that most definitely sounds like the problem if you&#39;re scaling AND THEN translating, obviously you won&#39;t get what you intend. It could also be a bug in that function, and I would check an Allegro 5 example that uses the function to see if it exhibits the same behavior.</p><p>[edit]
</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/615293/1012209#target">Don Freeman</a> said:</div><div class="quote"><p>
Edit:<br />Nevermind. <img src="http://www.allegro.cc/forums/smileys/rolleyes.gif" alt="::)" /> I feel dumb hahaha. I forgot that half y of the image is transparent on most of the sprites, so it just looked off by that much. I&#39;ll probably store these all in a structure during loading so I don&#39;t have to do stretching every draw cycle. Thanks all.
</p></div></div><p>
Ah.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Chris Katko)</author>
		<pubDate>Wed, 15 Apr 2015 21:10:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah, I&#39;m gonna clear the image to black during testing so I can see the edges of the images so something stupid like this doesn&#39;t happen again. <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Don Freeman)</author>
		<pubDate>Wed, 15 Apr 2015 21:19:51 +0000</pubDate>
	</item>
</rss>
