<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Palette Color</title>
		<link>http://www.allegro.cc/forums/view/590239</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sat, 24 Feb 2007 18:04:40 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Okay, common question, but I can not for the life of me connect these dots.  I&#39;m in 8-bit color depth and I&#39;ve got a palette of 256 colors.  I thought I could use makecol8 to produce one of the palette colors, but maybe I&#39;m doing something wrong.  Here, take a look at the following code:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">for</span><span class="k2">(</span><span class="k1">int</span> h <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> h <span class="k3">&lt;</span> <span class="n">256</span> <span class="k2">;</span> h<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span>
<span class="k2">{</span>
  
      <a href="http://www.allegro.cc/manual/rectfill" target="_blank"><span class="a">rectfill</span></a><span class="k2">(</span>buffer, buffer-&gt;w<span class="k3">/</span><span class="n">2</span>, h<span class="k3">*</span><span class="n">2</span>, buffer-&gt;w, h<span class="k3">*</span><span class="n">2</span><span class="k3">+</span><span class="n">2</span>, <a href="http://www.allegro.cc/manual/palette_color" target="_blank"><span class="a">palette_color</span></a><span class="k2">[</span>h<span class="k2">]</span><span class="k2">)</span><span class="k2">;</span>
  <a href="http://www.allegro.cc/manual/get_color" target="_blank"><span class="a">get_color</span></a><span class="k2">(</span>h,test<span class="k2">)</span><span class="k2">;</span>
      <a href="http://www.allegro.cc/manual/rectfill" target="_blank"><span class="a">rectfill</span></a><span class="k2">(</span>buffer, <span class="n">0</span>, h<span class="k3">*</span><span class="n">2</span>, buffer-&gt;w<span class="k3">/</span><span class="n">2</span>, h<span class="k3">*</span><span class="n">2</span><span class="k3">+</span><span class="n">2</span>, <a href="http://www.allegro.cc/manual/makecol8" target="_blank"><span class="a">makecol8</span></a><span class="k2">(</span>test-&gt;r,test-&gt;g,test-&gt;b<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
    
<span class="k2">}</span>
</pre></div></div><p>

That bit of code produces:<br /> <span class="remote-thumbnail"><span class="json">{"name":"591294","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/b\/0bb82e44a178f8d74de189e7e1ac2761.jpg","w":643,"h":481,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/b\/0bb82e44a178f8d74de189e7e1ac2761"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/0/b/0bb82e44a178f8d74de189e7e1ac2761-240.jpg" alt="591294" width="240" height="179" /></span></p><p>The colors on the right are the correct colors from the palette.  And lastly, what I ultimately <i>want</i> to do is to be able to pull a pixel from the bitmap and say it is # of the palette.  I&#39;m missing something, because all my logic/study has just led me in the circles, after reading (misinterpreting?) the manual for quite some time.</p><p>[edit]<br />No progress, other than I found out I could just use h instead of palette_color[h].  It seems the problem with makecol8 is it doesn&#39;t use the vga (0-63) colors like I thought it did.  I guess in the end, you have to convert them?  I&#39;m confused.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Onewing)</author>
		<pubDate>Sat, 24 Feb 2007 16:13:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
And lastly, what I ultimately want to do is to be able to pull a pixel from the bitmap and say it is # of the palette.
</p></div></div><p>
That&#39;s what getpixel does. Am I missing something?</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
It seems the problem with makecol8 is it doesn&#39;t use the vga (0-63) colors like I thought it did.
</p></div></div><p>
As per the manual, makecol8 takes RGB values in the range 0-255.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 24 Feb 2007 16:20:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>My bad, must&#39;ve been a long day.  The problem was I believed there was some connection between palettes and using makecol.  </p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
That&#39;s what getpixel does. Am I missing something?
</p></div></div><p>
I&#39;ve been in 32 bit for so long I was used to getpixel pulling a number that was more abstract (don&#39;t take me literally here), for lack of better terms.  However, logically it makes since considering I&#39;m in 8bit mode now.  I was taking it a step at a time, and since I couldn&#39;t get makecol to work, I didn&#39;t think getpixel would work.  So I spent all my time trying to figure out what the difference was there.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
As per the manual, makecol8 takes RGB values in the range 0-255.
</p></div></div><p>
Not so plainly though, nor directly under makecol8.  In fact, you have to go to makecol32:</p><div class="quote_container"><div class="title">manual said:</div><div class="quote"><p>
These functions convert colors from a hardware independent form (red, green, and blue values ranging 0-255) into various display dependent pixel formats.
</p></div></div><p>
And even &quot;these functions&quot; is a little...vague.  </p><p>And maybe I missed it somewhere, but the manual doesn&#39;t ever seem to say, &quot;this is how you use those colors you set up in your palette.&quot;
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Onewing)</author>
		<pubDate>Sat, 24 Feb 2007 16:39:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I&#39;ve been in 32 bit for so long I was used to getpixel pulling a number that was more abstract (don&#39;t take me literally here), for lack of better terms. However, logically it makes since considering I&#39;m in 8bit mode now.
</p></div></div><p>
Well, what it does is give you the colour value. In high/true colour mode, this is an RGB value. In 8 bit mode, the colour is the index in the palette (that&#39;s alwo why palette_color[n]=n in 8 bit mode; it&#39;s the converted RGB value in high/true colour mode).</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Not so plainly though, nor directly under makecol8. In fact, you have to go to makecol32:
</p></div></div><p>
No I don&#39;t:
</p><div class="quote_container"><div class="title">man makecol8 said:</div><div class="quote"><p>

makecol8(3)                     Allegro manual                     makecol8(3)</p><p>NAME<br />       makecol8,  makecol15, makecol16, makecol24, makecol32 - Converts an RGB<br />       value into a display dependent pixel format. Allegro  game  programming<br />       library.</p><p>SYNOPSIS<br />       #include &lt;allegro.h&gt;</p><p>       int makecol8(int r, int g, int b);</p><p>       int makecol15(int r, int g, int b);</p><p>       int makecol16(int r, int g, int b);</p><p>       int makecol24(int r, int g, int b);</p><p>       int makecol32(int r, int g, int b);<br />DESCRIPTION<br />       These  functions  convert colors from a hardware independent form (red,<br />       green, and blue values ranging 0-255) into  various  display  dependent<br />       pixel formats. Converting to 15, 16, 24, or 32-bit formats only takes a<br />       few shifts, so it is fairly efficient. Converting  to  an  8-bit  color<br />       involves  searching  the  palette  to  find the closest match, which is<br />       quite slow unless you have set up an RGB  mapping  table  (see  below).<br />       Example:</p><p>          /* 16 bit color version of green. */<br />          int green_color = makecol16(0, 255, 0);</p><p>RETURN VALUE<br />       Returns the requested RGB triplet in the specified color depth.
</p></div></div><p>
Or, <a href="http://alleg.sourceforge.net/stabledocs/en/alleg012.html#makecol8">http://alleg.sourceforge.net/stabledocs/en/alleg012.html#makecol8</a></p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
And maybe I missed it somewhere, but the manual doesn&#39;t ever seem to say, &quot;this is how you use those colors you set up in your palette.&quot;
</p></div></div><p>
There&#39;s nothing to say. It&#39;s no different from how you would use a colour in any other colour depth. Maybe I don&#39;t understand what you don&#39;t understand though...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 24 Feb 2007 16:50:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
No I don&#39;t:
</p></div></div><p>
Well, um, you do if you use the manual on a.cc, which is what I&#39;ve been using.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Maybe I don&#39;t understand what you don&#39;t understand though...
</p></div></div><p>
Oh, I&#39;m sure you don&#39;t understand most of what I don&#39;t understand, which is quite understandable.</p><p>Anywho, who it all makes sense now and very logically, computer-wise that is.  I look back now and I don&#39;t even really remember what I was having a problem with.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Onewing)</author>
		<pubDate>Sat, 24 Feb 2007 17:00:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Well, um, you do if you use the manual on a.cc, which is what I&#39;ve been using.
</p></div></div><p>
Ah, right! I forgot that the A.cc copy of the manual doesn&#39;t deal well with multiple functions grouped together in one heading.<br />It isn&#39;t <i>the</i> manual though. <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 24 Feb 2007 18:04:40 +0000</pubDate>
	</item>
</rss>
