<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>How to change the color of my bitmap</title>
		<link>http://www.allegro.cc/forums/view/589009</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Wed, 13 Dec 2006 00:14:18 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi hello, I have a question.</p><p>I drew this white polygon in Adobe Illustrator and i saved it as a bitmap with a pink background.</p><p>I can easily load it into my program, but I need to change the white to any other color I want, like green or purple. But the pink background needs to stay transparent. I think it should be easy but I&#39;m out of ideas.</p><p>Please help me <img src="http://www.allegro.cc/forums/smileys/cry.gif" alt=":&#39;(" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (peelemachine)</author>
		<pubDate>Sun, 10 Dec 2006 23:49:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes, it does sound simple, and with 256-colour bitmaps, it is. With anything else however, it&#39;s not.</p><p>There is a command in Allegro called draw_character() which is similar to draw_sprite() but functions similarly to the textprintf() commands in that you can define a solid colour to draw in. (Or with draw_character_ex(), a background colour too.)</p><p>However, even though you can only use this command with 256-colour bitmaps for the source (as far as I&#39;m aware), you can draw onto any other colour-depth bitmap with it.</p><p>Remembering too that with 256-colour bitmaps, translucency is defined as colour index 0 by default instead of bright magenta.</p><p>If you really must use a source bitmap with more than 256 colours you may need to use lit sprites, using the draw_lit_sprite() command and by setting up the blender functions within Allegro. This will eat away CPU time however and depending on the type of project you&#39;re working on, may not be practical to your framerate.</p><p>All of the commands I&#39;ve mentioned can be looked up in the manual, either on your computer in the allegro/docs folder or <a href="http://www.allegro.cc/manual">here</a>.</p><p>--- Kris Asick (Gemini)<br />--- <a href="http://www.pixelships.com">http://www.pixelships.com</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kris Asick)</author>
		<pubDate>Mon, 11 Dec 2006 00:13:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If it is practical you can prerender all of your bitmaps to all the colors you will need from the one base bitmap by creating a new bitmap of the same size and write a function to rip through the base bitmap and plot the pixel on the resulting bitmap by changing white to the desired color and magenta to magenta.  Now if it&#39;s a polygon you can use allegros polygon routines and have it rendered in real time using allegro.  If it&#39;s more complex and high color mode then you will have to prerender if you want obtainable speeds in your program.  This usually isn&#39;t a problem if you have colored team sprites or something, if it&#39;s going to change a lot of colors then you will eat up too much memory.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Steve Terry)</author>
		<pubDate>Mon, 11 Dec 2006 01:53:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> replace_colour<span class="k2">(</span><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>bmp, <span class="k1">int</span> curcolour, <span class="k1">int</span> newcolour<span class="k2">)</span> <span class="k2">{</span>
  <span class="k1">int</span> x, y<span class="k2">;</span>

  <span class="k1">for</span><span class="k2">(</span>y <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> y <span class="k3">&lt;</span> bmp-&gt;h<span class="k2">;</span> y<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span> <span class="k2">{</span>
    <span class="k1">for</span><span class="k2">(</span>x <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> x <span class="k3">&lt;</span> bmp-&gt;w<span class="k2">;</span> x<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span> <span class="k2">{</span>
      <span class="k1">if</span><span class="k2">(</span><a href="http://www.allegro.cc/manual/getpixel" target="_blank"><span class="a">getpixel</span></a><span class="k2">(</span>x, y<span class="k2">)</span> <span class="k3">=</span><span class="k3">=</span> curcolour<span class="k2">)</span> <a href="http://www.allegro.cc/manual/putpixel" target="_blank"><span class="a">putpixel</span></a><span class="k2">(</span>x, y, newcolour<span class="k2">)</span><span class="k2">;</span>
    <span class="k2">}</span>
  <span class="k2">}</span>

<span class="k2">}</span>
</pre></div></div><p>

Untested, but it should work.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (James Stanley)</author>
		<pubDate>Mon, 11 Dec 2006 01:53:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Sweet, thanks for the help.</p><p>I think I can make it work now. I don&#39;t have the internet at home yet, so it&#39;s hard to come on here sometimes. Thanks again <img src="http://www.allegro.cc/forums/smileys/cool.gif" alt="8-)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (peelemachine)</author>
		<pubDate>Wed, 13 Dec 2006 00:14:18 +0000</pubDate>
	</item>
</rss>
