<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Loading a PNG from a DATAFILE</title>
		<link>http://www.allegro.cc/forums/view/589915</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 06 Feb 2007 09:32:09 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m trying to load a PNG image that I saved as &quot;Other&quot; data in the Allegro datafile to a OpenLayer Bitmap. I&#39;m definately not doing it right since it&#39;s giving a runtime error in the Bitmap constructor.</p><p>Here is how I&#39;m trying to do it.
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/DATAFILE" target="_blank"><span class="a">DATAFILE</span></a> <span class="k3">*</span>dataFile <span class="k3">=</span> <a href="http://www.allegro.cc/manual/load_datafile" target="_blank"><span class="a">load_datafile</span></a><span class="k2">(</span><span class="s">"test data.dat"</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>bitmap <span class="k3">=</span> load_memory_png<span class="k2">(</span>dataFile<span class="k2">[</span><span class="n">0</span><span class="k2">]</span>.dat, <span class="k1">sizeof</span><span class="k2">(</span>dataFile<span class="k2">[</span><span class="n">0</span><span class="k2">]</span>.dat<span class="k2">)</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span> <span class="c">//loadpng library function</span>
Bitmap <span class="k3">*</span>newBitmap <span class="k3">=</span> Bitmap<span class="k2">(</span>bitmap, HAS_ALPHA_CHANNEL<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

I&#39;m sure someone knows the right to do this.</p><p>EDIT: Well I fixed it, didn&#39;t realize loadpng had functions to help with that.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GrantG)</author>
		<pubDate>Mon, 05 Feb 2007 22:50:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>FYI, the problem was the .dat pointer is only four bytes, so you&#39;re basically telling loadpng that the png data is only 4 bytes long. That fails and returns NULL, which means the Bitmap doesn&#39;t get made. For the size of the data, you want to use the .len field.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kitty Cat)</author>
		<pubDate>Tue, 06 Feb 2007 09:32:09 +0000</pubDate>
	</item>
</rss>
