<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Allegro 4.9.4: PNG support not working</title>
		<link>http://www.allegro.cc/forums/view/597677</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sat, 20 Sep 2008 09:08:40 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Is there anything special I need to do in order to get PNG support with the iio add-on? I have built the iio add-on with PNG support by pointing cmake to my zlib and png libraries but when I try to load the image with al_iio_load(&quot;whatever.png&quot;) it fails. I replaced that with iio_load_png(&quot;whatever.png&quot;) and the image loads fine.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Todd Cope)</author>
		<pubDate>Sat, 13 Sep 2008 02:29:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>do you tried al_iio_init();??</p><p>EDIT<br />sorry, I didn&#39;t see that iio_load_png was working <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /><br />could you tell us what is the error?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Wagner Soares)</author>
		<pubDate>Sat, 13 Sep 2008 02:32:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>al_iio_load() is returning NULL when the file actually exists. Somehow I think the PNG loader is not being registered by al_iio_init(). In the source file I notice that the PNG loader is only registered if ALLEGRO_CFG_IIO_HAVE_PNG is defined. Presumably that is supposed to be done automatically by the build system but maybe somehow it isn&#39;t.</p><p>Edit: I defined ALLEGRO_CFG_IIO_HAVE_PNG myself and it still fails to work.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Todd Cope)</author>
		<pubDate>Sat, 13 Sep 2008 02:40:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I had to run cmake 3 times for it to work.<br />first to generate &quot;CMakeCache.txt&quot;, you&#39;ll find 2 lines:
</p><div class="source-code snippet"><div class="inner"><pre><span class="c">//Path to a file.</span>
ZLIB_INCLUDE_DIR:PATH<span class="k3">=</span>C:\VSC\include

<span class="c">//Path to a library.</span>
ZLIB_LIBRARY:FILEPATH<span class="k3">=</span>C:\VSC\lib\zlib.lib
</pre></div></div><p>
if cmake couldn&#39;t find zlib, something like NOTFOUND (can&#39;t remeber, sorry) will be written.<br />after change the file and save it, run cmake again, and when you re-open the file, 2 PNG PATH lines will appear.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Wagner Soares)</author>
		<pubDate>Sat, 13 Sep 2008 02:51:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>All those things are correct in my &quot;CMakeCache.txt&quot; and it still behaves as I described above.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Todd Cope)</author>
		<pubDate>Sat, 13 Sep 2008 04:24:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>This is an interesting issue.  I tested myself under Linux with the latest SVN, and  al_iio_load loads a png file just fine.  If I ever end up in Windows I can try to install the 4.9.4 release and see what happens.</p><p>I did nothing special with cmake, but in Linux things tend to work automatically.  At least in my experience.  <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (StevenVI)</author>
		<pubDate>Sat, 13 Sep 2008 05:12:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
In the source file I notice that the PNG loader is only registered if ALLEGRO_CFG_IIO_HAVE_PNG is defined. Presumably that is supposed to be done automatically by the build system but maybe somehow it isn&#39;t.
</p></div></div><p>

Not even in include/allegro5/internal/aintern_iio_cfg.h?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Milan Mimica)</author>
		<pubDate>Sat, 13 Sep 2008 11:41:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Here is the contents of that file:
</p><div class="source-code snippet"><div class="inner"><pre><span class="c">/* #undef ALLEGRO_CFG_IIO_HAVE_PNG */</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Todd Cope)</author>
		<pubDate>Sun, 14 Sep 2008 01:17:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I would try to rebuild from scratch, with an empty CMake cache.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Milan Mimica)</author>
		<pubDate>Sun, 14 Sep 2008 11:59:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Did that two or three times already.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Todd Cope)</author>
		<pubDate>Sun, 14 Sep 2008 19:49:00 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>For it to work for me, I have to add c:/mingw/lib and c:/mingw/include to my PATH before running CMake. Then it finds everything (zlib, png, freetype, etc).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Mon, 15 Sep 2008 02:58:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Just tried it and indeed it did find everything I had but the runtime issue still remains. Even though libpng and libz are linked into liba5_iio, somehow al_iio_load() is not aware of this. I can still use iio_load_png() directly but that is not exposed by the API therefore I shouldn&#39;t really be doing that.</p><p>I may tinker with it myself this afternoon and see if I can find out what is going on.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Todd Cope)</author>
		<pubDate>Mon, 15 Sep 2008 20:46:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Are you sure you&#39;re calling al_iio_init()?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Mon, 15 Sep 2008 23:02:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes. I am loading other images as well (PCX, TGA) and all those work fine.</p><p>Edit: I have confirmed that the PNG handler is not being added during al_iio_init().</p><p>Edit 2: ALLEGRO_CFG_IIO_HAVE_PNG is not defined when &quot;iio.c&quot; is being compiled even though cmake shows that it has found PNG support. I&#39;m not sure how cmake works but according to the &quot;CMakeLists.txt&quot; file ALLEGRO_CFG_IIO_HAVE_PNG is defined when PNG_FOUND is true. If that&#39;s the case then somehow that information must not be getting passed along to the compiler.</p><p>Edit 3: I redid everything from scratch in a new folder and it worked. I guess I screwed something up in all my tinkering with the settings.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Todd Cope)</author>
		<pubDate>Tue, 16 Sep 2008 01:08:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ah, ok... that&#39;s a good thing. It means I don&#39;t have to hunt around for obscure bugs. Thanks for all your testing!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Tue, 16 Sep 2008 04:56:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hmm, it is not working. For some reason when I was rebuilding my project, a new executable wasn&#39;t being created. I remedied that problem and now the original problem still stands.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Todd Cope)</author>
		<pubDate>Thu, 18 Sep 2008 02:17:28 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Could you apply the attached patch and try it?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Thu, 18 Sep 2008 04:35:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The patch fixed it!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Todd Cope)</author>
		<pubDate>Thu, 18 Sep 2008 19:15:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ok, thanks for testing. I&#39;ll apply it to svn.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Thu, 18 Sep 2008 22:50:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Todd, can you tell me which version of CMake and which C compiler you&#39;re using? The patch Trent posted is only a hack (which will be reverted), and I&#39;d like to figure out why it wasn&#39;t working before.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Wang)</author>
		<pubDate>Fri, 19 Sep 2008 09:54:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m using &quot;CMake 2.6-patch 1.&quot; My compiler is &quot;gcc version 3.4.2 (mingw-special).&quot;
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Todd Cope)</author>
		<pubDate>Sat, 20 Sep 2008 02:14:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I tried it in a virtual machine with Windows XP, and a completely fresh installation of mingw. CMake 2.6-patch 1, gcc 3.4.2. Works for me.</p><p>I unpacked allegro-4.9.4 in c:\allegro, and built in a subdirectory called &quot;Build&quot;. c:\allegro\Build\include\allegro5\internal\aintern_iio_cfg.h contains:
</p><div class="source-code snippet"><div class="inner"><pre><span class="p">#define ALLEGRO_CFG_IIO_HAVE_PNG</span>
</pre></div></div><p>

ex_bitmap loaded a PNG file okay.</p><p>So, I don&#39;t know what to make of it.  To help you debug it, this is how it&#39;s supposed to work:</p><p>- CMake finds zlib and libpng<br />- CMake generates aintern_iio_cfg.h from aintern_iio_cfg.h.cmake<br />- iio.c includes iio.h, which includes aintern_iio_cfg.h<br />- iio.c checks if ALLEGRO_CFG_IIO_HAVE_PNG is defined and registers the handler</p><p>I can only imagine that you have another file called aintern_iio_cfg.h somewhere, which is being picked up instead.  Try entering some gibberish into aintern_iio_cfg.h which would cause the C compiler to abort, just to make sure it&#39;s looking at the right file.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Wang)</author>
		<pubDate>Sat, 20 Sep 2008 09:08:40 +0000</pubDate>
	</item>
</rss>
