<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Fascinating palette behavior...</title>
		<link>http://www.allegro.cc/forums/view/587939</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 13 Oct 2006 03:50:09 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code snippet"><div class="inner"><pre>        <a href="http://www.allegro.cc/manual/RGB" target="_blank"><span class="a">RGB</span></a> rgb <span class="k3">=</span> <span class="k2">{</span><span class="n">1</span>,<span class="n">0</span>,<span class="n">0</span><span class="k2">}</span><span class="k2">;</span>
  <a href="http://www.allegro.cc/manual/set_color" target="_blank"><span class="a">set_color</span></a><span class="k2">(</span><span class="n">1</span>, <span class="k3">&amp;</span>rgb<span class="k2">)</span><span class="k2">;</span>
  <span class="k1">int</span> col <span class="k3">=</span> <a href="http://www.allegro.cc/manual/palette_color" target="_blank"><span class="a">palette_color</span></a><span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k2">;</span><span class="c">//returns 4!</span>
</pre></div></div><p>

I have run into a problem running this code, as you can see I set the first color in the palette to RGB(1,0,0) and then I retreive the value from the current palette.</p><p>The problem is that instead of returning 1 it returns 4!</p><p>Is there a bug here or did I do something wrong?</p><p>Sorry if this has been answered before and feel free to direct me to the manual as appropritate <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Mon, 09 Oct 2006 03:59:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>IIRC the palette colors have 6-bit resolution, not full 8-bit so maybe that has something to do with it? If you extend the number one from 0...63 to 0...255, youll get 4.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Fladimir da Gorf)</author>
		<pubDate>Mon, 09 Oct 2006 04:10:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hmm... yes, using get_color() does seem to do the trick of retreiving the correct value(I assume it handles the 6 bit calculations on its own)...</p><p>But that is not viable, since the same happens in my actual program. I write to a 8bpp bmp with this color(#1) and then blit it to a 32bpp and get the pixel color, and also get the incorrect color returned (in this case 4)... <img src="http://www.allegro.cc/forums/smileys/undecided.gif" alt=":-/" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Mon, 09 Oct 2006 04:20:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That&#39;s because it simply can&#39;t know what the value used to be. No matter what you pass between 1 and 4, you&#39;ll get 4 out - the number resolution is reduced.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Fladimir da Gorf)</author>
		<pubDate>Mon, 09 Oct 2006 04:27:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah, that&#39;s just the way palettes work. It&#39;s not a bug and you did nothing wrong. Palette colours are taken from a 6 bit colour space (in each component) so rgb = {1, 0, 0} is actually the same as makecol(4,0,0) in 32bpp.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (miran)</author>
		<pubDate>Mon, 09 Oct 2006 12:10:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I see, thanks!</p><p>I just ended up writing directly to the palette_color and not using the set_color() function at all...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Wed, 11 Oct 2006 07:22:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>...you wouldn&#39;t happen to be Siege_Lord of Clan EotA, would you?</p><p>Edit: I just realized that probably should&#39;ve been a PM. Waste of server space on me.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Fri, 13 Oct 2006 03:50:09 +0000</pubDate>
	</item>
</rss>
