<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Sprite loading problem</title>
		<link>http://www.allegro.cc/forums/view/607370</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 19 May 2011 14:16:55 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi</p><p>I was searching for the answer in many places but nobody could help me yet. like this:
</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><a href="http://www.allegro.cc/manual/al_init"><span class="a">al_init</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span> 
<span class="number">  2</span>  <a href="http://www.allegro.cc/manual/ALLEGRO_DISPLAY"><span class="a">ALLEGRO_DISPLAY</span></a> <span class="k3">*</span>display <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_create_display"><span class="a">al_create_display</span></a><span class="k2">(</span><span class="n">640</span>, <span class="n">480</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  3</span>  <a href="http://www.allegro.cc/manual/al_set_window_title"><span class="a">al_set_window_title</span></a><span class="k2">(</span>display, <span class="s">"Allegro 5"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  4</span>  <a href="http://www.allegro.cc/manual/al_clear_to_color"><span class="a">al_clear_to_color</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/al_map_rgba"><span class="a">al_map_rgba</span></a><span class="k2">(</span><span class="n">0</span>, <span class="n">0</span>, <span class="n">0</span>, <span class="n">255</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  5</span>  <span class="c">// koniec inicjalizacji okna - jest ok.  </span>
<span class="number">  6</span>
<span class="number">  7</span>  <span class="k1">if</span><span class="k2">(</span><span class="k3">!</span><a href="http://www.allegro.cc/manual/al_init_image_addon"><span class="a">al_init_image_addon</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span>
<span class="number">  8</span>    <span class="k1">return</span> <span class="k3">-</span><span class="n">1</span><span class="k2">;</span>
<span class="number">  9</span>
<span class="number"> 10</span>  <span class="k1">if</span><span class="k2">(</span><span class="k3">!</span><a href="http://www.allegro.cc/manual/al_filename_exists"><span class="a">al_filename_exists</span></a><span class="k2">(</span><span class="s">"D:/C++/Allegro_drawing/Allegro_drawing/sprite.bmp"</span><span class="k2">)</span><span class="k2">)</span>
<span class="number"> 11</span>    <span class="k1">return</span> <span class="k3">-</span><span class="n">4</span><span class="k2">;</span>
<span class="number"> 12</span>
<span class="number"> 13</span>  <span class="k1">if</span><span class="k2">(</span><span class="k3">!</span><a href="http://www.allegro.cc/manual/al_is_system_installed"><span class="a">al_is_system_installed</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span>
<span class="number"> 14</span>    <span class="k1">return</span> <span class="k3">-</span><span class="n">5</span><span class="k2">;</span>
<span class="number"> 15</span>
<span class="number"> 16</span>   <a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a> <span class="k3">*</span>img <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_load_bitmap"><span class="a">al_load_bitmap</span></a><span class="k2">(</span><span class="s">"sprite.bmp"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 17</span>  <span class="k1">if</span><span class="k2">(</span><span class="k3">!</span>img<span class="k2">)</span>
<span class="number"> 18</span>    <span class="k1">return</span> <span class="k3">-</span><span class="n">2</span><span class="k2">;</span>
</div></div><p>
Sprite is in the internal directory named like the project (as you can see). It always ends returning -2. I included needed header files. <br />So what could possibly go wrong?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (auliszek)</author>
		<pubDate>Thu, 19 May 2011 12:02:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><span class="source-code"><span class="s">"D:/C++/Allegro_drawing/Allegro_drawing/sprite.bmp"</span> <span class="k3">!</span><span class="k3">=</span> <span class="s">"sprite.bmp"</span></span><br />What&#39;s your operating system?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (weapon_S)</author>
		<pubDate>Thu, 19 May 2011 12:15:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Windows xp home</p><p>It is not equal in theory, but it is also the directory where main.cpp is. When i load font this way it works.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (auliszek)</author>
		<pubDate>Thu, 19 May 2011 12:29:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If you use a relative path like sprite.bmp, then you have to run the program from the same directory as sprite.bmp, or the same directory as your program, if they&#39;re the same.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Thu, 19 May 2011 12:41:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You can set the current directory to where the executable is like this, if that&#39;s where your data is:
</p><div class="source-code snippet"><div class="inner"><pre>ALLEGRO_PATH appdir <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_standard_path"><span class="a">al_get_standard_path</span></a><span class="k2">(</span>ALLEGRO_RESOURCES_PATH, ALLEGRO_NATIVE_PATH_SEP<span class="k2">)</span><span class="k2">;</span>
<span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span>appdir<span class="k2">)</span>
    <span class="k1">return</span> <span class="k3">-</span><span class="n">6</span><span class="k2">;</span>
<span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span><a href="http://www.allegro.cc/manual/al_change_directory"><span class="a">al_change_directory</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/al_path_cstr"><span class="a">al_path_cstr</span></a><span class="k2">(</span>appdir<span class="k2">)</span><span class="k2">)</span><span class="k2">)</span>
    <span class="k1">return</span> <span class="k3">-</span><span class="n">7</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_destroy_path"><span class="a">al_destroy_path</span></a><span class="k2">(</span>appdir<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
If that doesn&#39;t work, maybe the BMP file is an a weird format?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (torhu)</author>
		<pubDate>Thu, 19 May 2011 12:54:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>But when i do sth like:<br />al_load_bitmap(&quot;D:/C++/Allegro_drawing/Allegro_drawing/sprite.bmp&quot;);<br />it also doesn&#39;t load my sprite. Why is that? Its not a relative path then.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (auliszek)</author>
		<pubDate>Thu, 19 May 2011 13:11:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>As Torhu mentioned, the BMP file could be in a wrong format.  Try loading/saving it with MS Paint, and see if the problem persists.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (LennyLen)</author>
		<pubDate>Thu, 19 May 2011 13:32:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah, this totally worked <img src="http://www.allegro.cc/forums/smileys/cheesy.gif" alt=":D" /><br />Thx, but one more question - if for example i&#39;m using photoshop to edit pictures, with what parameters i should save them with?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (auliszek)</author>
		<pubDate>Thu, 19 May 2011 13:55:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>According to this <a href="http://www.allegro.cc/forums/thread/607294">thread</a>, somebody had similar problem with a 32bit BMP, 24bit was fine.<br />If you can provide a sample non-loading bitmap, Allegro coders can have a look at what&#39;s the problem with such images.</p><p>(edit: From looking at the <a href="http://svn.tomasu.org/index.cgi/allegro/view/allegro/branches/5.0/addons/image/bmp.c">source</a>, the load routine will only accept some very specific R G B bitmasks... for 32bit, only ARGB order is accepted.)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Audric)</author>
		<pubDate>Thu, 19 May 2011 14:10:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Photoshop should be able to save to .png or possibly .tga.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Thu, 19 May 2011 14:11:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks guyz <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (auliszek)</author>
		<pubDate>Thu, 19 May 2011 14:16:55 +0000</pubDate>
	</item>
</rss>
