<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>rgb order</title>
		<link>http://www.allegro.cc/forums/view/580015</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Wed, 19 Apr 2006 16:25:26 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I looked through the allegro sources (namely the function makeacol32), and noticed that there&#39;s a way to determine the active rgb-order, as follows:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">bool</span> RGB_direction<span class="k2">(</span><span class="k2">)</span>
<span class="k2">{</span>
  <span class="c">// true: for r-g-b</span>
  <span class="c">// false: for b-g-r</span>
  <span class="k1">return</span> <span class="k2">(</span><span class="k2">(</span>_rgb_r_shift_32 <span class="k3">=</span><span class="k3">=</span> <span class="n">16</span><span class="k2">)</span> <span class="k3">&amp;</span><span class="k3">&amp;</span> <span class="k2">(</span>_rgb_g_shift_32 <span class="k3">=</span><span class="k3">=</span> <span class="n">8</span><span class="k2">)</span> <span class="k3">&amp;</span><span class="k3">&amp;</span> <span class="k2">(</span>_rgb_b_shift_32 <span class="k3">=</span><span class="k3">=</span> <span class="n">0</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Geoman)</author>
		<pubDate>Tue, 18 Apr 2006 14:31:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>And so ? What is the question ?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GullRaDriel)</author>
		<pubDate>Tue, 18 Apr 2006 17:02:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Im guessing Geoman just wanted to share, which is good i guess <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jonatan Hedborg)</author>
		<pubDate>Tue, 18 Apr 2006 17:07:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>[edited]</p><p>I&#39;m dumb today <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GullRaDriel)</author>
		<pubDate>Tue, 18 Apr 2006 17:11:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It can come in handy in case someone wants to write a color-byte directly to the screen memory, so I thought I&#39;d mention it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Geoman)</author>
		<pubDate>Tue, 18 Apr 2006 17:38:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I remember that once biting me in the butt when I was making my own bitmap loading code; I could have used that once upon a time. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (23yrold3yrold)</author>
		<pubDate>Tue, 18 Apr 2006 17:41:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It&#39;s pretty trivial, but when you need it, you don&#39;t usually think of it.</p><p>Another way, using only the public allegro api (thus api compatible) would be:
</p><div class="source-code snippet"><div class="inner"><pre><span class="c">// assuming 24 bpp</span>
<span class="k1">bool</span> rgb_ordering<span class="k2">(</span><span class="k2">)</span> <span class="k2">{</span>
  <span class="k1">int</span> c <span class="k3">=</span> <a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><span class="k2">(</span><span class="n">255</span>, <span class="n">0</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
  <span class="k1">return</span> <span class="k2">(</span><span class="k2">(</span>c <span class="k3">&amp;</span> <span class="n">0xFF</span><span class="k2">)</span> <span class="k3">!</span><span class="k3">=</span> <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Tue, 18 Apr 2006 17:45:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Darn it, you&#39;re right <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /><br />The example I gave also only requires the public API, btw.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Geoman)</author>
		<pubDate>Tue, 18 Apr 2006 18:04:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>_rgb_r_shift_32 isn&#39;t in the public api AFAIK. At least at a quick glance, I couldn&#39;t find it in the docs.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Wed, 19 Apr 2006 12:15:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It starts with an _, so it isn&#39;t public. It&#39;s in the user headers because there&#39;s some inline code and macros that use it, but you aren&#39;t supposed to use it directly.</p><p>You can&#39;t really go around assuming any order, anyway. RGBA and ABGR isn&#39;t the only combination there may be, after all. ARGB, BGRA, etc, are also valid.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kitty Cat)</author>
		<pubDate>Wed, 19 Apr 2006 12:22:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You have a point...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Geoman)</author>
		<pubDate>Wed, 19 Apr 2006 14:03:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It appears DIB&#39;s are given to you with a specific color ordering (which makes sense, since it&#39;s Device Independant (Bitmap)). As you can see, it checks to see if the dest is the same order as the source, and just does a straight copy if so, otherwise it pulls out the individual colors and reconstructs them with makecol32. You can&#39;t simply check where the red value ends up to determine the order for all 4 values, though.</p><p>EDIT:<br />Sure, edit while I&#39;m typing a reply. There&#39;s no love for the cats. <img src="http://www.allegro.cc/forums/smileys/cry.gif" alt=":&#39;(" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kitty Cat)</author>
		<pubDate>Wed, 19 Apr 2006 14:12:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah... well, I noticed that too after rereading the gdi.c file, so I edited my post. I didn&#39;t realize this earlier.</p><p>Yet, having the A located in the lower byte is kinda unusual isn&#39;t it ?</p><p>For now, I&#39;ll simply write some code that does not support videocards that have A values in the low byte. It&#39;s good to know that this limitation exists, though <img src="http://www.allegro.cc/forums/smileys/sad.gif" alt=":(" /> Those hardware designers really don&#39;t have software issues in mind when they design their stuff, do they.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Geoman)</author>
		<pubDate>Wed, 19 Apr 2006 14:17:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Part of the problem is CPU endianesse. Since, for example 32-bit modes are stored as 4 bytes, it&#39;s usually packed into a 32-bit int. However, the bytes in a 32-bit int can be stored in a different order between different types of CPUs.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kitty Cat)</author>
		<pubDate>Wed, 19 Apr 2006 14:28:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I happen to be very fond of cats <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p><p>If I&#39;d summarize, then if I target pentium-compatible computers (which is my main interest), then the location of A should always be the high byte ?</p><p>Yet the R and B location are video-card dependent ?</p><p>Is the G value always in the center of the rgb/bgr triplet ?</p><p>I suppose that the endianness is really only a problem on apples and unixes ?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Geoman)</author>
		<pubDate>Wed, 19 Apr 2006 15:38:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You&#39;ll typically find RGB or BGR with A on one side or the other. But this isn&#39;t gauranteed. I believe there are some cards that do RBG (and thus GBR). It&#39;s best not to assume at all.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kitty Cat)</author>
		<pubDate>Wed, 19 Apr 2006 15:52:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code snippet"><div class="inner"><pre><span class="k1">int</span> c <span class="k3">=</span> <a href="http://www.allegro.cc/manual/makeacol32" target="_blank"><span class="a">makeacol32</span></a><span class="k2">(</span><span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>, <span class="n">4</span><span class="k2">)</span><span class="k2">;</span>
<span class="c">// now find the 1 for red, the 2 for green, and so on.</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Wed, 19 Apr 2006 16:25:26 +0000</pubDate>
	</item>
</rss>
