<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>I&#39;m haveing trouble with 256-color bitmaps.</title>
		<link>http://www.allegro.cc/forums/view/581530</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 25 Apr 2006 21:59:17 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>First the game is set up to be at any color depth.<br />Second I got all my data in a datafile.</p><p>Now I want to be able to use the palette in the datafile with my 256-color bitmaps (also in the datafile) by bliting it on another bitmap whose color depth may not be 256-colors.</p><p>How can I do all of this?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (FalseMasterJ)</author>
		<pubDate>Tue, 25 Apr 2006 20:07:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Generally, allegro was not intended to mix bitmaps of different color depths at all. That said:<br />To use a palette from a datafile, you have to cast the dat member of the corresponding datafile record to a PALETTE (or an RGB*). You can pass that to set_palette() like so:
</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> dat<span class="k2">;</span>

<a href="http://www.allegro.cc/manual/load_datafile" target="_blank"><span class="a">load_datafile</span></a><span class="k2">(</span>dat, <span class="s">"data.dat"</span><span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/set_palette" target="_blank"><span class="a">set_palette</span></a><span class="k2">(</span><span class="k2">(</span><a href="http://www.allegro.cc/manual/RGB" target="_blank"><span class="a">RGB</span></a><span class="k3">*</span><span class="k2">)</span>dat<span class="k2">[</span>PALETTE_PCX<span class="k2">]</span>.dat<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
Assuming that PALETTE_PCX is defined in the (properly included) datafile header and that the corresponding datafile entry is in fact a palette. </p><p>If you are in a &gt;8bpp mode, then you need to set the proper color conversion. The easiest (and least error prone) procedure is this:<br />1) set_color_conversion(COLORCONV_TOTAL | COLORCONV_KEEP_TRANS);<br />2) Use load_datafile_object() to temporarily load the palette from the datafile<br />3) set the palette<br />4) load_datafile() the entire datafile; color conversion takes care of the palette and everything else for you. The resulting bitmaps will be in the current color depth</p><p>Alternatively, you can:<br />1) disable color conversion<br />2) load the datafile in one go<br />3) find the palette in the datafile and set it<br />4) enable color conversion<br />Note that only a few functions support color conversions (blit() and to some extent draw_sprite() do), while others will just assume equal color depths (stretch_blit() etc.) for performance reasons.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Tue, 25 Apr 2006 20:36:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thank you Tobias Dammers. This was a problem that stumped me in almost every allegro game I made. since I could figure it out I just make the whole game one or the other.<br />but this time I must do a 8-bit to 24-bit conversion. The first way that you metion works very well. The second way is usefull too. In-case I want to change palette rapidly (e.g. to make a NES like watterfall).<br />Thank you for all you help.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (FalseMasterJ)</author>
		<pubDate>Tue, 25 Apr 2006 21:59:17 +0000</pubDate>
	</item>
</rss>
