<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>finding out bitmap pixel info</title>
		<link>http://www.allegro.cc/forums/view/587116</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sat, 19 Aug 2006 20:59:39 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I need to make a program that can tell me what color a specific pixel (with a specific coordinate) from a BMP has. Even smth as simple as this:</p><p>Pixel(0,0): Color Green; Pixel(1,0): Color Blue...<br />..................................................<br />Pixel(0,344): Color Magenta etc...</p><p>till the end of file.<br />Actual code would be very helpful.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (qwertq)</author>
		<pubDate>Sat, 19 Aug 2006 11:58:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Go look at the manual and find the getpixel functions.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SonShadowCat)</author>
		<pubDate>Sat, 19 Aug 2006 12:01:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code snippet"><div class="inner"><pre> <span class="c">/*</span>
<span class="c">  * Returns an array containing colors</span>
<span class="c">  */</span>
 <span class="k1">int</span> <span class="k3">*</span>get_pixels_color_from<span class="k2">(</span><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>image<span class="k2">)</span>
 <span class="k2">{</span>
    <span class="k1">static</span> <span class="k1">int</span> colors<span class="k2">[</span>image-&gt;w<span class="k3">*</span>image-&gt;h<span class="k2">]</span><span class="k2">;</span>
    <span class="k1">int</span> f, c<span class="k2">;</span>

 <span class="k1">for</span> <span class="k2">(</span>f <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span>f <span class="k3">&lt;</span> image-&gt;w<span class="k2">;</span>f<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span>
    <span class="k1">for</span> <span class="k2">(</span>c <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span>c <span class="k3">&lt;</span> image-&gt;h<span class="k2">;</span>c<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span>
        colors<span class="k2">[</span>f<span class="k3">*</span>image-&gt;w<span class="k3">+</span>c<span class="k2">]</span> <span class="k3">=</span> <a href="http://www.allegro.cc/manual/getpixel" target="_blank"><span class="a">getpixel</span></a><span class="k2">(</span>f,c<span class="k2">)</span><span class="k2">;</span>

 <span class="k1">return</span> colors<span class="k2">;</span>
 <span class="k2">}</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Maikol)</author>
		<pubDate>Sat, 19 Aug 2006 20:47:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Maikol: 1. Your code does the same thing as blit() and 2. Your code doesn&#39;t even compile.</p><p>qwertq: If you really need to find the names of the colours in the bitmap, do the following for each pixel:</p><p>1. Read colour with getpixel().<br />2. Decompose to RGB components with getr(), getg() and getb().<br />3. Convert to HSV colourspace with rgb_to_hsv().<br />4. Check the H, S and V components. H&#39;s value ranges from 0 to 360, where 0 is red, 120 is green, 240 is blue and 360 is again red. 60 is yellow, 180 is cyan, 300 is purple and so on. So if H is between 15 and 45, you can say the colour is orange. The value of S ranges from 0 to 1. If S is 0 (or very close to 0) you can say the colour is a shade of gray. Which shade depends on the value of V, which ranges from 0 to 1. 0 is black, 1 is white and everything between is gray.</p><p>If you don&#39;t actually need to put names to the colours, but just want to read integer values for pixels, then follow SonShadowCat&#39;s advice to RTFM.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (miran)</author>
		<pubDate>Sat, 19 Aug 2006 20:59:39 +0000</pubDate>
	</item>
</rss>
