<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>al_load_bitmap() pretends to load a file.</title>
		<link>http://www.allegro.cc/forums/view/617043</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 15 Sep 2017 21:31:16 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>So I&#39;m using Allegro 5 in VS2015 and gave the package loaded from NuGET. I also have the image addon installed in my solution. </p><p>We can assume that al_init();  al_init_image_addon(); has been called properly and I can draw to the display OK?</p><p>I run the following code:</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">void</span> load_gfx<span class="k2">(</span><span class="k1">void</span><span class="k2">)</span>
<span class="number">  2</span><span class="k2">{</span>
<span class="number">  3</span>  <span class="k1">if</span> <span class="k2">(</span><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">"gfx\\gui.png"</span>, gui<span class="k2">)</span><span class="k2">)</span> <span class="k2">{</span>
<span class="number">  4</span>    <a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"failed to load gui!\n"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  5</span>  <span class="k2">}</span>
<span class="number">  6</span>  <span class="k1">if</span> <span class="k2">(</span>gui <span class="k3">=</span><span class="k3">=</span> NULL<span class="k2">)</span><span class="k2">{</span>
<span class="number">  7</span>    <a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"HAH, Fooled you, I didn't actually load jack! :D\n"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  8</span>  <span class="k2">}</span>
<span class="number">  9</span><span class="k2">}</span>
</div></div><p>

output:<br /><tt>HAH, Fooled you, I didn&#39;t actually load jack! :D</tt></p><p>So, yea, it &quot;loads&quot; the file with no errors and yet my gui bitmap is still strangely NULL? Let&#39;s look at the allegro log!</p><pre>
d3dx9    I        d3d_d3dx9.cpp:88   _imp_load_d3dx9_module_version   [   0.06907] Module &quot;d3dx9_43.dll&quot; loaded.
stdio    D         file_stdio.c:109  file_stdio_fopen                 [   0.06919] opening gfx\gui.png rb
</pre><p>
It loaded! It loaded and.. what? What&#39;s going on?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (nshade)</author>
		<pubDate>Fri, 15 Sep 2017 07:46:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You can check if the file is where you expect it to be by trying <span class="source-code"><a href="http://www.allegro.cc/manual/al_filename_exists"><span class="a">al_filename_exists</span></a></span> first on it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Fri, 15 Sep 2017 08:18:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The problem isn&#39;t the file isn&#39;t found. Its that the file is being loaded by the allegro system, and then never assigned to the bitmap pointer.</p><p>Just to oblige this theory, I&#39;ll change the code a bit.</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> load_gfx<span class="k2">(</span><span class="k1">void</span><span class="k2">)</span>
<span class="k2">{</span>
  <span class="k1">if</span> <span class="k2">(</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">"gfx\\gui.png"</span><span class="k2">)</span><span class="k2">)</span>
  <span class="k2">{</span>
    <a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"filename is there!\n"</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><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">"gfx\\gui.png"</span>, gui<span class="k2">)</span><span class="k2">)</span> <span class="k2">{</span>
    <a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"failed to load gui!\n"</span><span class="k2">)</span><span class="k2">;</span>
  <span class="k2">}</span>
  <span class="k1">if</span> <span class="k2">(</span>gui <span class="k3">=</span><span class="k3">=</span> NULL<span class="k2">)</span><span class="k2">{</span>
    <a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"HAH, Fooled you, I didn't actually load jack!\n"</span><span class="k2">)</span><span class="k2">;</span>
  <span class="k2">}</span>
<span class="k2">}</span>
</pre></div></div><p>

I get 
</p><pre>
filename is there!
HAH, Fooled you, I didn&#39;t actually load jack!
</pre><p>

and my log file looks like this
</p><pre>
stdio    D         file_stdio.c:109  file_stdio_fopen                 [   0.13417] opening gfx\gui.png rb
d3d      D         d3d_disp.cpp:1188 real_choose_bitmap_format        [   0.13442] Fake format
d3d      D         d3d_disp.cpp:1188 real_choose_bitmap_format        [   0.13444] Fake format
...
</pre><p>
----------------</p><p>If I remove the png file from my filesystem and run it, I&#39;ll get this...</p><pre>
failed to load gui!
HAH, Fooled you, I didn&#39;t actually load jack!
</pre><p>

and the log looks like this..
</p><pre>
stdio    D         file_stdio.c:109  file_stdio_fopen                 [   0.12894] opening gfx\gui.png rb
bitmap   W          bitmap_io.c:211  al_load_bitmap_flags             [   0.12898] Failed loading gfx\gui.png with .png handler.
</pre><p>
----------------<br />So why is the system physically loading my .png file and not assigning it as a bitmap?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (nshade)</author>
		<pubDate>Fri, 15 Sep 2017 11:19:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>This will probably hurt, but the syntax (API) is <span class="source-code">gui<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">"gfx\\gui.png"</span><span class="k2">)</span></span>, not <span class="source-code"><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">"gfx\\gui.png"</span>, gui<span class="k2">)</span></span><br />Sorry.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Audric)</author>
		<pubDate>Fri, 15 Sep 2017 13:14:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>ALLEGRO_BITMAP *al_load_bitmap(const char *filename)</p><p>Yea, I need to stop reading API documentation at 3:00am :/
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (nshade)</author>
		<pubDate>Fri, 15 Sep 2017 18:09:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Wondering why the compiler didn&#39;t spit out compile error on <span class="source-code"><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">"gfx\\gui.png"</span>, gui<span class="k2">)</span></span> since there is an extra argument.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (DanielH)</author>
		<pubDate>Fri, 15 Sep 2017 20:46:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I just had to log in at work to ask the same thing... <br />&quot;Wait a minute, I was giving it two arguments! That should of been a full stop compile time error.&quot;</p><p>My guess is it&#39;s using some funny formatting things ala printf();</p><p>I bet you al_load_bitmap(&quot;%s&quot;, filestring) works...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (nshade)</author>
		<pubDate>Fri, 15 Sep 2017 21:31:16 +0000</pubDate>
	</item>
</rss>
