<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Drawing translucent Bitmap.</title>
		<link>http://www.allegro.cc/forums/view/612132</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 28 Feb 2013 23:32:23 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi,<br />I draw a bitmap in normal mode but in certain<br />condition I want to draw it in translucent mode.(Look like disable)</p><p>In this way I draw the bitmap:
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/al_draw_bitmap_region"><span class="a">al_draw_bitmap_region</span></a><span class="k2">(</span>BTNBMP, curFrame, framePos, frameWidth, frameHeight, cx, cy, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

Using A5.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (coder123)</author>
		<pubDate>Thu, 28 Feb 2013 09:41:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I believe you want <span class="source-code"><a href="http://www.allegro.cc/manual/al_draw_tinted_bitmap_region"><span class="a">al_draw_tinted_bitmap_region</span></a></span>.</p><p>ie: <span class="source-code"><a href="http://www.allegro.cc/manual/al_draw_tinted_bitmap_region"><span class="a">al_draw_tinted_bitmap_region</span></a><span class="k2">(</span>bitmap, <a href="http://www.allegro.cc/manual/al_map_rgba_f"><span class="a">al_map_rgba_f</span></a><span class="k2">(</span><span class="n">1</span>, <span class="n">1</span>, <span class="n">1</span>, <span class="n">0</span>.<span class="n">5</span><span class="k2">)</span>, sx, sy, sw, sh, dx, dy, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span></span></p><p>Will draw the bitmap at 50% translucency.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Thu, 28 Feb 2013 11:51:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/612132/977700#target">Thomas Fjellstrom</a> said:</div><div class="quote"><p>ie: al_draw_tinted_bitmap_region(bitmap, al_map_rgba_f(1, 1, 1, 0.5), sx, sy, sw, sh, dx, dy, 0);</p></div></div><p>
You should multiply each of the color components by the opacity:
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">float</span> opacity <span class="k3">=</span> <span class="n">0</span>.<span class="n">5</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/ALLEGRO_COLOR"><span class="a">ALLEGRO_COLOR</span></a> tint <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_map_rgba_f"><span class="a">al_map_rgba_f</span></a><span class="k2">(</span><span class="n">1</span><span class="k3">*</span>opacity, <span class="n">1</span><span class="k3">*</span>opacity, <span class="n">1</span><span class="k3">*</span>opacity, opacity<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_draw_tinted_bitmap_region"><span class="a">al_draw_tinted_bitmap_region</span></a><span class="k2">(</span>bitmap, tint, sx, sy, sw, sh, dx, dy, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

(interesting fact: &quot;tint&quot; is not the correct term in color theory for this type of color change, but it&#39;s what allegro uses.)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mark Oates)</author>
		<pubDate>Thu, 28 Feb 2013 18:17:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hm, I grabbed that example from the docs. but I think you&#39;re right. To use the code I gave, you&#39;d have to disable pre-multiplied alpha.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Thu, 28 Feb 2013 23:14:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thank you.</p><p>That&#39;s what I need.</p><p><img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (coder123)</author>
		<pubDate>Thu, 28 Feb 2013 23:32:23 +0000</pubDate>
	</item>
</rss>
