<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>How to load a bitmap????</title>
		<link>http://www.allegro.cc/forums/view/585640</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sun, 28 May 2006 15:45:14 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hello guys,</p><p>I&#39;m a newbie in using allegro.</p><p>I have created a bitmap that contains frames of a character in 4 gray color set with a tool I wrote myself in .NET. The tool can encode 8x8, 16x16 or 32x32 sprites.</p><p>The bitmap that contains the frames is a 24bppRGB format and the size is 16x16. The .NET function loos like this:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">private</span> <span class="k1">void</span> ExportToWindows<span class="k2">(</span>string fileName<span class="k2">)</span>
<span class="k2">{</span>
  <span class="k1">int</span> width <span class="k3">=</span> _ilTiles.Images<span class="k2">[</span><span class="n">0</span><span class="k2">]</span>.Width<span class="k2">;</span>
  <span class="k1">int</span> height <span class="k3">=</span> _ilTiles.Images<span class="k2">[</span><span class="n">0</span><span class="k2">]</span>.Height<span class="k2">;</span>
  Bitmap bmp <span class="k3">=</span> <span class="k1">new</span> Bitmap<span class="k2">(</span>_ilTiles.Images.Count <span class="k3">*</span> width, height, PixelFormat.Format24bppRgb<span class="k2">)</span><span class="k2">;</span>
  Graphics g <span class="k3">=</span> Graphics.FromImage<span class="k2">(</span>bmp<span class="k2">)</span><span class="k2">;</span>

  <span class="k1">for</span> <span class="k2">(</span><span class="k1">int</span> i<span class="k3">=</span><span class="n">0</span><span class="k2">;</span> i <span class="k3">&lt;</span> _ilTiles.Images.Count<span class="k2">;</span> i<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span>
  <span class="k2">{</span>
    Rectangle <a href="http://www.allegro.cc/manual/rect" target="_blank"><span class="a">rect</span></a> <span class="k3">=</span> <span class="k1">new</span> Rectangle<span class="k2">(</span>i <span class="k3">*</span> width, <span class="n">0</span>, width, height<span class="k2">)</span><span class="k2">;</span>
    g.DrawImage<span class="k2">(</span>_ilTiles.Images<span class="k3">&lt;</span>i&gt;, <a href="http://www.allegro.cc/manual/rect" target="_blank"><span class="a">rect</span></a><span class="k2">)</span><span class="k2">;</span>
  <span class="k2">}</span>
  bmp.Save<span class="k2">(</span>fileName<span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

So, for loading the bitmap with allegro, I have used the set_color_depth() function with 24 as mode before calling the load_bitmap function.</p><p>The problem I have is that I ALWAYS get a NULL pointer when I try to load the bitmap file, thus, no matter the format I use to encode the bitmap.</p><p>Can anybody help me please and tell me how to load correctly the bmp please???</p><p>Best regards.</p><p>Fred.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (boulifb)</author>
		<pubDate>Sun, 28 May 2006 01:35:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Double-check that the bitmap is in the right directory. Then show us your Allegro code.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (gnolam)</author>
		<pubDate>Sun, 28 May 2006 03:54:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>is is a STANDARD bmp ?<br />re-save it using MS-Paint...  you&#39;d be amazed at how many apps create non-standard BMP files.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (A J)</author>
		<pubDate>Sun, 28 May 2006 05:21:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Actually, the format of the bitmap was incorrect.<br />I had to forced the format when saving:
</p><div class="source-code snippet"><div class="inner"><pre>bmp.Save<span class="k2">(</span>fileName, ImageFormat.Bmp<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

and it works fine this way.</p><p>Thanks <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p><p>Fred.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (boulifb)</author>
		<pubDate>Sun, 28 May 2006 15:45:14 +0000</pubDate>
	</item>
</rss>
