<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>al_draw_text with alpha</title>
		<link>http://www.allegro.cc/forums/view/606537</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 03 Mar 2011 19:24:40 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There is a way to draw text with &quot;al_draw_text&quot; with Alpha? I tried:
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/al_draw_text"><span class="a">al_draw_text</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/font"><span class="a">font</span></a>, <a href="http://www.allegro.cc/manual/al_map_rgba"><span class="a">al_map_rgba</span></a><span class="k2">(</span><span class="n">255</span>, <span class="n">255</span> ,<span class="n">255</span> ,<span class="n">120</span><span class="k2">)</span>, <span class="n">635</span>, <span class="n">645</span>, <span class="n">0</span>, <span class="s">"aloha"</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

But didn&#39;t work, there is a way? or should I use bitmap fonts?</p><h2>Conclusion:</h2><p>

Allegro Uses pre-multiplied alpha by default <span class="source-code"> <a href="http://www.allegro.cc/manual/al_map_rgba"><span class="a">al_map_rgba</span></a></span> works great with bitmaps but doesn&#39;t seems to work with text. </p><p><span class="source-code"><a href="http://www.allegro.cc/manual/al_map_rgba_f"><span class="a">al_map_rgba_f</span></a></span> works fine with text, but instead of use a parameter number from 0-255 for RBG colors uses a ranging from 0.0f-1.0f.</p><p>So if you wan to convert a color from 0-255 to 0.0f-1.0f you need to use division. </p><p>Ex: normal RGB (180,120,100,127.5) <br />180/255=0.705<br />120/255=0.470<br />100/255=0.392<br />127/255=0.5</p><p>Would be:<br />Allegro RGB <span class="source-code"><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">0</span>.<span class="n">705</span>,<span class="n">0</span>.<span class="n">470</span>,<span class="n">0</span>.<span class="n">392</span>.<span class="n">0</span>.<span class="n">5</span><span class="k2">)</span></span></p><p>And if you need convert from 0.0f-1.0f to 0-255 you need to use uses multiplication.</p><p>Ex: normal RGB (0.705,0.470,0.392,0.5) <br />0.705*255=180<br />0.470*255=120<br />0.392*255=100<br />0.5*255=127.5
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (AMCerasoli)</author>
		<pubDate>Sat, 26 Feb 2011 18:41:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It should work its just pre multiplied alpha is on by default so at the top of your render loop try:</p><p>al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA);</p><p><a href="http://docs.liballeg.org/graphics.html#al_set_blender">http://docs.liballeg.org/graphics.html#al_set_blender</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jmasterx)</author>
		<pubDate>Sat, 26 Feb 2011 18:51:00 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks man, now is working!</p><p>But, when it says: &quot;Sets the function to use for blending for the current thread&quot; what is saying?</p><p>The current tread is the whole tread right? because I saw something about &quot;threading interface&quot; which allows me to do multi threading? but if I&#39;m not using it there is just one thread, right?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (AMCerasoli)</author>
		<pubDate>Sat, 26 Feb 2011 19:08:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>What they mean I think is that it affects all of your displays. If you have many displays, you must set blender for each one.</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> render<span class="k2">(</span><span class="k2">)</span>
<span class="k2">{</span>
  <span class="c">//set display</span>
  <span class="c">//set blender</span>
  <span class="c">//draw</span>

  <span class="c">//set display2</span>
  <span class="c">//set blender</span>
  <span class="c">//draw</span>
<span class="k2">}</span>
</pre></div></div><p>

But if you only have 1 display (1 window) you don&#39;t have to worry about it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jmasterx)</author>
		<pubDate>Sat, 26 Feb 2011 19:35:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Oh I see.</p><p>But have just notice this problem:</p><p>I put <span class="source-code"><a href="http://www.allegro.cc/manual/al_set_blender"><span class="a">al_set_blender</span></a><span class="k2">(</span>ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA<span class="k2">)</span><span class="k2">;</span></span><br /> before all the drawing calls.</p><p><span class="remote-thumbnail"><span class="json">{"name":"603492","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/e\/2e1ea87d9d52d4ffa11dfc586179bb35.jpg","w":505,"h":718,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/e\/2e1ea87d9d52d4ffa11dfc586179bb35"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/2/e/2e1ea87d9d52d4ffa11dfc586179bb35-240.jpg" alt="603492" width="240" height="341" /></span></p><p>Should be like the PhotoShop version. <br />If I remove <span class="source-code"><a href="http://www.allegro.cc/manual/al_set_blender"><span class="a">al_set_blender</span></a><span class="k2">(</span>ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA<span class="k2">)</span><span class="k2">;</span></span> it works but again can&#39;t draw transparent text. <img src="http://www.allegro.cc/forums/smileys/shocked.gif" alt=":o" /></p><p>I&#39;m using: <span class="source-code"> <a href="http://www.allegro.cc/manual/al_draw_tinted_bitmap"><span class="a">al_draw_tinted_bitmap</span></a><span class="k2">(</span>PNG, <a href="http://www.allegro.cc/manual/al_map_rgba"><span class="a">al_map_rgba</span></a><span class="k2">(</span><span class="n">255</span>, <span class="n">255</span>, <span class="n">255</span>, <span class="n">255</span><span class="k2">)</span>, <span class="n">0</span>, <span class="n">0</span>, <span class="n">0</span> <span class="k2">)</span><span class="k2">;</span></span></p><p>it&#39;s a PNG which already have transparency.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (AMCerasoli)</author>
		<pubDate>Sat, 26 Feb 2011 20:37:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>This is because Photoshop premultiplies Alpha for Bitmaps so try to set it back to premultiplied before drawing bitmaps and before loading bitmaps, but use the other blender to draw text.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jmasterx)</author>
		<pubDate>Sat, 26 Feb 2011 20:41:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Or premultiply the color you draw the text with then you never need to touch the blender.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Sat, 26 Feb 2011 22:36:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>But by default Allegro is also premultiplaying alpha right?</p><p>Because if I don&#39;t modify the blending, Allegro draw it the same as Photoshop does.</p><p>&quot;premultiply the color you draw the text&quot; sounds better, that doesn&#39;t mean that if I premultiply the white color, all the bitmaps that are using the white color are going to be affected?</p><p>1) How can I premultiply just one color? (if that is what you&#39;re suggesting)<br />2) Isn&#39;t changing the blending, CPU expensive?<br />3) By default, Allegro premultiply alpha?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (AMCerasoli)</author>
		<pubDate>Sun, 27 Feb 2011 00:05:22 +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/606537/905382#target">AMCERASOLI</a> said:</div><div class="quote"><p>
1) How can I premultiply just one color? (if that is what you&#39;re suggesting)<br />2) Isn&#39;t changing the blending, CPU expensive?<br />3) By default, Allegro premultiply alpha?
</p></div></div><p>
1) Use <span class="source-code"><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">255</span>.<span class="n">0f</span><span class="k3">*</span><span class="n">0</span>.<span class="n">5f</span> , <span class="n">127</span>.<span class="n">0f</span><span class="k3">*</span><span class="n">0</span>.<span class="n">5f</span> , <span class="n">64</span>.<span class="n">0f</span><span class="k3">*</span><span class="n">0</span>.<span class="n">5f</span> , <span class="n">0</span>.<span class="n">5f</span><span class="k2">)</span></span>. Premultiplying the alpha means multiplying it yourself, which makes no sense to me.<br />2) Probably not. I&#39;m guessing it just sets some flags.<br />3) Yes
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Sun, 27 Feb 2011 00:20:31 +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/606537/905382#target">AMCERASOLI</a> said:</div><div class="quote"><p>But by default Allegro is also premultiplaying alpha right?</p></div></div><p>Last time I checked, Allegro had no multiplayer functions at all. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /></p><p>Premultiplied alpha means this: <br />The individual RGB components of any pixel <b>source</b> data are interpreted in the alpha blending step as having already been multiplied by some alpha value, so the alpha blending step does not multiply the source RGB components with the source A component anymore to determine what gets blended with the RGB components of the target pixel data.</p><p>Additional reading:<br /><a href="http://en.wikipedia.org/wiki/Alpha_compositing">http://en.wikipedia.org/wiki/Alpha_compositing</a><br />A5 specific: <a href="http://docs.liballeg.org/graphics.html#al_set_blender">http://docs.liballeg.org/graphics.html#al_set_blender</a><br />Look at those formulas and the description below. Do the math and feel enlightened afterwards (Note how the A component of the source color is still important for calculating the amount of each RGB value from the target color in the alpha blending step.).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Dennis)</author>
		<pubDate>Sun, 27 Feb 2011 00:54:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" /><img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" /><img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" /> hahahahaha</p><p>That would be good a Multiplayer function!!.</p><p>You just have to call al_set_multiplayer(ALLEGRO_PC * pc); and that&#39;s it.</p><p>I would like to do it the Elias way. But I don&#39;t even know what means the &#39;f&#39; letter after the numbers. Can someone drop a link? I don&#39;t know how to search (google:&quot;the &quot;f&quot; letter after a number c++&quot;?), it&#39;s something related with Hexadecimals right?</p><p>The <span class="source-code"> <a href="http://www.allegro.cc/manual/al_map_rgba_f"><span class="a">al_map_rgba_f</span></a></span> function that Edgar gave me, seems to instead of get transparent, become black (when I modify it), because if I use it as he gave it to me, the text is drawn blue. This surely is because I don&#39;t know how to use it. I never saw anything about that in my C++ Book. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (AMCerasoli)</author>
		<pubDate>Sun, 27 Feb 2011 03:42:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Sorry, I used <span class="source-code"><a href="http://www.allegro.cc/manual/al_map_rgba_f"><span class="a">al_map_rgba_f</span></a></span> wrong. The values go from 0.0 to 1.0, not 0 to 255.
</p><div class="source-code snippet"><div class="inner"><pre><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">0f</span><span class="k3">*</span><span class="n">0</span>.<span class="n">5f</span> , <span class="n">0</span>.<span class="n">5f</span><span class="k3">*</span><span class="n">0</span>.<span class="n">5f</span> , <span class="n">0</span>.<span class="n">25f</span><span class="k3">*</span><span class="n">0</span>.<span class="n">5f</span> , <span class="n">0</span>.<span class="n">5f</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
Would give you a slightly desaturated orange at 50% opacity.</p><p>The _f at the end of al_map_rgba_f just means it takes floating point values. The f at the end of the number values means they are floating point values.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Sun, 27 Feb 2011 04:02:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>But why are you multiplying all that? isn&#39;t the same: <span class="source-code"><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">0</span>.<span class="n">5f</span> , <span class="n">0</span>.<span class="n">25f</span> , <span class="n">0</span>.<span class="n">125</span> , <span class="n">0</span>.<span class="n">5f</span><span class="k2">)</span></span> well actually it is, I tried it.</p><p>I like this way since I don&#39;t have to use blending. But if I do <span class="source-code"><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">0</span>.<span class="n">5f</span> , <span class="n">0</span>.<span class="n">25f</span> , <span class="n">0</span>.<span class="n">125</span> , <span class="n">0</span>.<span class="n">0f</span><span class="k2">)</span></span> It gets white instead of transparent. I have been reading and that is one of the difference between premultiply and the other way. </p><p>But then what I have to do?, changing the whole blending mode it seems unnecessary I don&#39;t know.</p><p>I want to make an &quot;appearing effect&quot;. from completely invisible to visible.</p><p>PS: Oh boy, jmasterx already have told me that premultiplied is on by default, and I asked again, I didn&#39;t see it <img src="http://www.allegro.cc/forums/smileys/shocked.gif" alt=":o" /><img src="http://www.allegro.cc/forums/smileys/shocked.gif" alt=":o" />. I didn&#39;t process correctly the info <img src="http://www.allegro.cc/forums/smileys/lipsrsealed.gif" alt=":-X" />.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (AMCerasoli)</author>
		<pubDate>Sun, 27 Feb 2011 04:31:34 +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/606537/905441#target">AMCERASOLI</a> said:</div><div class="quote"><p>But why are you multiplying all that? isn&#39;t the same: al_map_rgba_f(0.5f , 0.25f , 0.125 , 0.5f) well actually it is, I tried it.</p></div></div><p>
Of course it&#39;s the same.<br />But first, it&#39;s an example, and second, doing the multiplication explicitly can be clearer. It&#39;s evaluated at compile-time anyway.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sun, 27 Feb 2011 07:01:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I did change the values with <span class="source-code"><a href="http://www.allegro.cc/manual/al_set_blender"><span class="a">al_set_blender</span></a></span> and then set it back, but I&#39;m getting this effect, and I really don&#39;t like it.</p><p><span class="remote-thumbnail"><span class="json">{"name":"603498","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/e\/0e0e895fbf9444353e9b5164277536a4.jpg","w":243,"h":159,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/e\/0e0e895fbf9444353e9b5164277536a4"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/0/e/0e0e895fbf9444353e9b5164277536a4-240.jpg" alt="603498" width="240" height="157" /></span></p><p>That black border.</p><p>How does work <span class="source-code"><a href="http://www.allegro.cc/manual/al_map_rgb_f"><span class="a">al_map_rgb_f</span></a></span>?</p><p>Can someone show me an example drawing text completely transparent with <span class="source-code"><a href="http://www.allegro.cc/manual/al_map_rgb_f"><span class="a">al_map_rgb_f</span></a></span>? no matter what color it&#39;s.</p><p>Isn&#39;t as simple as used to... the unique way I can make it complytly transparent is doing this: <span class="source-code"><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">0</span>.<span class="n">0f</span> , <span class="n">0</span>.<span class="n">0f</span> , <span class="n">0</span>.<span class="n">0f</span> , <span class="n">0</span>.<span class="n">0f</span><span class="k2">)</span></span>, the thing is now I don&#39;t know how to control those variables... RGB are in most applications, but know what can I use as reference?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (AMCerasoli)</author>
		<pubDate>Mon, 28 Feb 2011 00:21:56 +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/606537/905564#target">AMCERASOLI</a> said:</div><div class="quote"><p>..but know what can I use as reference?</p></div></div><p>
Yes, the manual: <a href="http://docs.liballeg.org/graphics.html#al_set_blender">http://docs.liballeg.org/graphics.html#al_set_blender</a><br />and <a href="http://docs.liballeg.org/graphics.html#al_map_rgb_f">http://docs.liballeg.org/graphics.html#al_map_rgb_f</a><br />It explains what&#39;s happening in detail. Also, read my previous post (and the links I provided).</p><p>Be patient. Read those sections of the manual slowly and make sure you understand each sentence before reading the next one. If there are any words you don&#39;t understand, look them up.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Dennis)</author>
		<pubDate>Mon, 28 Feb 2011 00:47:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It&#39;s very simple:</p><div class="source-code snippet"><div class="inner"><pre><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">0</span>, <span class="n">0</span>, <span class="n">0</span>, <span class="n">0</span><span class="k2">)</span> <span class="c">// 0% opaque (fully transparent)</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">0</span>.<span class="n">25</span>, <span class="n">0</span>.<span class="n">25</span>, <span class="n">0</span>.<span class="n">25</span>, <span class="n">0</span>.<span class="n">25</span><span class="k2">)</span> <span class="c">// 25% opaque</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">0</span>.<span class="n">50</span>, <span class="n">0</span>.<span class="n">50</span>, <span class="n">0</span>.<span class="n">50</span>, <span class="n">0</span>.<span class="n">50</span><span class="k2">)</span> <span class="c">// 50% opaque (half transparent)</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="n">1</span>, <span class="n">1</span>, <span class="n">1</span><span class="k2">)</span> <span class="c">// 100% opaque (default, no transparency)</span>
</pre></div></div><p>

This is when using the default blending mode only of course.</p><p>[edit: The black border will appear if you change to non-pre-multiplied alpha, so <b>don&#39;t</b> do that. Leave everything at the defaults unless you know what you are doing.]
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Mon, 28 Feb 2011 01:02:16 +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/606537/905573#target">Elias</a> said:</div><div class="quote"><p>
The black border will appear if you change to non-pre-multiplied alpha, so don&#39;t do that.
</p></div></div><p>
Why would there be a black border if you&#39;re not using pre multiplied alpha? Shouldn&#39;t the outcome be the same as if you were using premultiplied alpha?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Mon, 28 Feb 2011 03:32:14 +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/606537/905573#target">Elias</a> said:</div><div class="quote"><p>Leave everything at the defaults unless you know what you are doing.</p></div></div><p>..and to reach a point where you know what you&#39;re doing, it helps to read and understand manuals, to look up unknown words and to seek more details about a topic and not just copy &amp; pasting examples.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Dennis)</author>
		<pubDate>Mon, 28 Feb 2011 04:00:35 +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/606537/905599#target">Edgar Reynaldo</a> said:</div><div class="quote"><p>Why would there be a black border if you&#39;re not using pre multiplied alpha? Shouldn&#39;t the outcome be the same as if you were using premultiplied alpha?</p></div></div><p>

Not if you use any kind of filtering (which I assume he&#39;s doing, don&#39;t see how there could be dark borders otherwise) - and that&#39;s precisely the reason why we switched to using pre-multipled alpha. Linear-interpolation-alpha just doesn&#39;t work with the way OpenGL/DirectX do interpolation.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Mon, 28 Feb 2011 16:18:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Black borders appear when I&#39;m not using pre-multiplied alpha. But anyway thack a lot Elias that examples help me a lot, I know that I gonna have to read, what Dennis gave me, but I already solve my problem.</p><p>The thing is now I have no reference, if I see for example a text in HTML/PhotoShop/etc, which use simple RGB, with the maximum amount of color been always 255.</p><p>What I have to do to transform that to this type of RGB, when the maximum amount of color is 1.0?. I haven&#39;t read the links above, so if I&#39;m saying something that I can find there, just don&#39;t even bother...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (AMCerasoli)</author>
		<pubDate>Mon, 28 Feb 2011 18:30:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Just multiply the value between 0.0 and 1.0 with 255 and there you go <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" /><br />The other way around: just divide by 255.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (J-Gamer)</author>
		<pubDate>Wed, 02 Mar 2011 01:06:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>N/A
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jmasterx)</author>
		<pubDate>Wed, 02 Mar 2011 02:05:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Err... jmaster, it&#39;s what I said... With that part of the phrase, I meant when going from photoshop/inkscape/... values to allegro values. So here is something clearer.</p><p>When converting from the allegro values to the photoshop/inkscape/... values, multiply with 255.<br />When going from the photoshop/inkscape/... to allegro values divide by 255.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (J-Gamer)</author>
		<pubDate>Wed, 02 Mar 2011 19:14:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks to all problem solved! <img src="http://www.allegro.cc/forums/smileys/cheesy.gif" alt=":D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (AMCerasoli)</author>
		<pubDate>Thu, 03 Mar 2011 03:22:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>For some reason the concept hasn&#39;t quite sunk in with all the allegroids, yet.  When this thread comes up again, <i>nobody</i> should mention the <span class="source-code"><a href="http://www.allegro.cc/manual/al_set_blender"><span class="a">al_set_blender</span></a><span class="k2">(</span>ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA<span class="k2">)</span></span> and/or the <span class="source-code">ALLEGRO_NO_PREMULTIPLIED_ALPHA</span> flag as a solution.  It does not &quot;return things to how they were before.&quot; Specifically, <a href="http://www.allegro.cc/forums/thread/606101">half-opacity is gray</a>, you get text outlines, etc.</p><p>Those two are not a working solution.  (In fact, I think ALLEGRO_NO_PREMULTIPLIED_ALPHA should be removed. <img src="http://www.allegro.cc/forums/smileys/lipsrsealed.gif" alt=":-X" />) </p><p>The <i>correct</i> solution is &quot;you&#39;ll need to multiply all your color components by the alpha value.  For example:
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">float</span> alpha <span class="k3">=</span> <span class="n">0</span>.<span class="n">3f</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/ALLEGRO_COLOR"><span class="a">ALLEGRO_COLOR</span></a> color <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">0</span>.<span class="n">7</span><span class="k3">*</span>alpha, <span class="n">0</span>.<span class="n">3</span><span class="k3">*</span>alpha, <span class="n">0</span>.<span class="n">6</span><span class="k3">*</span>alpha, alpha<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>&quot; or, the similar answer using 0-255 values.</p><p>Thank you. <br /><img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mark Oates)</author>
		<pubDate>Thu, 03 Mar 2011 09:16:03 +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/606537/906059#target">Mark Oates</a> said:</div><div class="quote"><p>
For some reason the concept hasn&#39;t quite sunk in with all the allegroids, yet. 
</p></div></div><p>
I haven&#39;t used A5 yet, but well personally I just don&#39;t get it either.</p><div class="quote_container"><div class="title">Mark Oates said:</div><div class="quote"><p>
The correct solution is &quot;you&#39;ll need to multiply all your color components by the alpha value.  For example:
</p></div></div><p>
The problem is, it should work the same way whether you multiply the alpha yourself or whether Allegro multiplies it for you.</p><p>Using &#39;filtering&#39; on a bitmap with alpha makes no sense to me, because then the color values in the pixels with zero alpha are used to blend the edges. So you better pick the right color values for your zero alpha pixels, or you&#39;re screwed and you get funky outlines.</p><p>So the real problem is that you can&#39;t pick sensible values for zero alpha pixels with filtering because it should be mixed with the background color instead.</p><p>I&#39;m reading Shawn Hargreaves blogs linked from <a href="http://www.allegro.cc/forums/thread/606101/899074#target">Elias&#39;s response to anomalous blending</a>, and maybe it makes sense and maybe it doesn&#39;t. I&#39;m not sure yet.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Thu, 03 Mar 2011 10:03:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I really think a nice flag which would state weather allegro&#39;s color mapping functions will be multiplying the colors for you would be very useful.</p><p>By this I mean, if the flag is set, a call to al_map_rgba would do:</p><p>al_map_rgba(r * a, g * a, b * a, a);</p><p>and would return a pre multiplied ALLEGRO_COLOR.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jmasterx)</author>
		<pubDate>Thu, 03 Mar 2011 10:19:26 +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/606537/906062#target">jmasterx</a> said:</div><div class="quote"><p>By this I mean, if the flag is set, a call to al_map_rgba would do:</p><p>al_map_rgba(r * a, g * a, b * a, a);</p></div></div><p>I think that&#39;s a good idea.</p><p>Right now, I use these two functions quite a bit:</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span><span class="k1">static</span> <span class="k1">inline</span> <a href="http://www.allegro.cc/manual/ALLEGRO_COLOR"><span class="a">ALLEGRO_COLOR</span></a> color_hex<span class="k2">(</span><span class="k1">const</span> <span class="k1">char</span> <span class="k3">*</span>hex, <span class="k1">float</span> a<span class="k3">=</span><span class="n">1</span>.<span class="n">0f</span><span class="k2">)</span>
<span class="number">  2</span><span class="k2">{</span>
<span class="number">  3</span>  <a href="http://www.allegro.cc/manual/ALLEGRO_COLOR"><span class="a">ALLEGRO_COLOR</span></a> color <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_color_html"><span class="a">al_color_html</span></a><span class="k2">(</span>hex<span class="k2">)</span><span class="k2">;</span>
<span class="number">  4</span>  color.a <span class="k3">=</span> a<span class="k2">;</span>
<span class="number">  5</span>  color.r <span class="k3">*</span><span class="k3">=</span> a<span class="k2">;</span>
<span class="number">  6</span>  color.g <span class="k3">*</span><span class="k3">=</span> a<span class="k2">;</span>
<span class="number">  7</span>  color.b <span class="k3">*</span><span class="k3">=</span> a<span class="k2">;</span>
<span class="number">  8</span>  <span class="k1">return</span> color<span class="k2">;</span>
<span class="number">  9</span><span class="k2">}</span>
<span class="number"> 10</span>
<span class="number"> 11</span><span class="k1">static</span> <span class="k1">inline</span> <a href="http://www.allegro.cc/manual/ALLEGRO_COLOR"><span class="a">ALLEGRO_COLOR</span></a> color_name<span class="k2">(</span><span class="k1">const</span> <span class="k1">char</span> <span class="k3">*</span>name, <span class="k1">float</span> a<span class="k3">=</span><span class="n">1</span>.<span class="n">0f</span><span class="k2">)</span>
<span class="number"> 12</span><span class="k2">{</span>
<span class="number"> 13</span>  <a href="http://www.allegro.cc/manual/ALLEGRO_COLOR"><span class="a">ALLEGRO_COLOR</span></a> color <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_color_name"><span class="a">al_color_name</span></a><span class="k2">(</span>name<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 14</span>  color.a <span class="k3">=</span> a<span class="k2">;</span>
<span class="number"> 15</span>  color.r <span class="k3">*</span><span class="k3">=</span> a<span class="k2">;</span>
<span class="number"> 16</span>  color.g <span class="k3">*</span><span class="k3">=</span> a<span class="k2">;</span>
<span class="number"> 17</span>  color.b <span class="k3">*</span><span class="k3">=</span> a<span class="k2">;</span>
<span class="number"> 18</span>  <span class="k1">return</span> color<span class="k2">;</span>
<span class="number"> 19</span><span class="k2">}</span>
</div></div><p>

Some time ago, I had a convenience function:<br /><span class="source-code"><span class="k1">static</span> <span class="k1">inline</span> <a href="http://www.allegro.cc/manual/ALLEGRO_COLOR"><span class="a">ALLEGRO_COLOR</span></a> color<span class="k2">(</span><span class="k1">const</span> <span class="k1">char</span> <span class="k3">*</span>identifier, <span class="k1">float</span> alpha<span class="k3">=</span><span class="n">1</span>.<span class="n">0</span><span class="k2">)</span><span class="k2">;</span></span><br />that would identify <span class="source-code">identifier</span> as a hex or name string, and would handle them accordingly.  I should bring that bad boy back.  <img src="http://www.allegro.cc/forums/smileys/cool.gif" alt="8-)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mark Oates)</author>
		<pubDate>Thu, 03 Mar 2011 10:33:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There would be no problem adding convenience versions of al_map_rgb* which multiply in the alpha component, if only someone could suggest decent names.</p><p>For now, I create my own makecol.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Wang)</author>
		<pubDate>Thu, 03 Mar 2011 10:59:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>al_map_premultiplied_rgba ? or a flag and use the same functions
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jmasterx)</author>
		<pubDate>Thu, 03 Mar 2011 11:12:00 +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/606537/906064#target">Peter Wang</a> said:</div><div class="quote"><p>if only someone could suggest decent names.</p></div></div><p>I think the al_map_rgb* functions should, by default, multiply the components by the alpha.</p><p>But, if you <span class="source-code">ALLEGRO_NO_PREMULTIPLIED_ALPHA</span> then they will not.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mark Oates)</author>
		<pubDate>Thu, 03 Mar 2011 11:15:14 +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/606537/906066#target">Mark Oates</a> said:</div><div class="quote"><p> I think the al_map_rgb* functions should, by default, multiply the components by the alpha.</p><p>But, if you ALLEGRO_NO_PREMULTIPLIED_ALPHA then they will not.<br /> </p></div></div><p>

I was hoping Allegro 5.0.0 was going to work like that.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jmasterx)</author>
		<pubDate>Thu, 03 Mar 2011 11:18:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I haven&#39;t <i>completely</i> thought through what else it could affect, but it seems to make sense.  Since it&#39;s essentially what&#39;s happening to a bitmap&#39;s colors when you&#39;re loading them, it should also happen with the mapped colors.</p><p>[edit]however, I seem to recall that xma makes you multiply the components explicitly... hmm...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mark Oates)</author>
		<pubDate>Thu, 03 Mar 2011 11:24:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The flag used for bitmap loading is a necessary evil. For colors, it would be another annoying thing I&#39;d have to check for and disable in library code.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Thu, 03 Mar 2011 11:39:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>ALLEGRO_NO_PREMULTIPLIED_ALPHA is only a bitmap flag that affects how allegro_image loads images. It has no other bearing. The rest of Allegro really doesn&#39;t care if you use the convention or not, which is all it is.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Wang)</author>
		<pubDate>Thu, 03 Mar 2011 11:43:53 +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/606537/906070#target">Peter Wang</a> said:</div><div class="quote"><p>ALLEGRO_NO_PREMULTIPLIED_ALPHA is only a bitmap flag that affects how allegro_image loads images. It has no other bearing. The rest of Allegro really doesn&#39;t care if you use the convention or not, which is all it is.
</p></div></div><p>Hmm... I see...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mark Oates)</author>
		<pubDate>Thu, 03 Mar 2011 11:45:31 +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/606537/906062#target">jmasterx</a> said:</div><div class="quote"><p>I really think a nice flag which would state weather allegro&#39;s color mapping functions will be multiplying the colors for you would be very useful.</p></div></div><p>
It could potentially slow you down quite a bit as well, if you&#39;re doing an extra comparison in a tight loop.</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/606537/906064#target">Peter Wang</a> said:</div><div class="quote"><p>There would be no problem adding convenience versions of al_map_rgb* which multiply in the alpha component, if only someone could suggest decent names.</p></div></div><p>
Agreed.<br />How about <span class="source-code">al_map_alpha_rgba<span class="k2">(</span><span class="k2">)</span></span>?<br />By the way, having functions that converts from non-pre-multiplied alpha to pre-multiplied alpha and back would be useful too.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Thu, 03 Mar 2011 18:57:32 +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/606537/906087#target">Evert</a> said:</div><div class="quote"><p>
How about al_map_alpha_rgba()?
</p></div></div><p>

Or maybe al_map_premultipled_rgba(). In both cases you likely want to keep your custom color functions/macros though so not sure it&#39;s necessary.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Thu, 03 Mar 2011 19:24:40 +0000</pubDate>
	</item>
</rss>
