<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>translucent putpixel</title>
		<link>http://www.allegro.cc/forums/view/588851</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 04 Dec 2006 16:01:03 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>hi,<br />    i&#39;ve got a 32 bit bitmap (lucky me) and I need to draw black pixels on it at varying degrees of translucency. i&#39;ve tried this
</p><div class="source-code snippet"><div class="inner"><pre>
<a href="http://www.allegro.cc/manual/_putpixel32" target="_blank"><span class="a">_putpixel32</span></a><span class="k2">(</span>bmp, x, y, <a href="http://www.allegro.cc/manual/makeacol32" target="_blank"><span class="a">makeacol32</span></a><span class="k2">(</span><span class="n">0</span>, <span class="n">0</span>, <span class="n">0</span>, <span class="n">128</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

 but this draws solid black pixels. Can someone help please ?</p><p>Also, I was wondering why functions like putpixel always have an int arg for the colour when they don&#39;t use a palette in non 8 bit modes.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (William Labbett)</author>
		<pubDate>Sat, 02 Dec 2006 16:49:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">William Labbett said:</div><div class="quote"><p>
i&#39;ve got a 32 bit bitmap (lucky me) and I need to draw black pixels on it at varying degrees of translucency. i&#39;ve tried this</p><p>_putpixel32(bmp, x, y, makeacol32(0, 0, 0, 128));</p><p>but this draws solid black pixels. Can someone help please ?
</p></div></div><p>

Check out <a href="http://www.allegro.cc/manual/api/transparency-and-patterned-drawing/truecolor-transparency/set_trans_blender">translucent drawing</a> in the manual.</p><p>some code like this should do the trick:
</p><div class="source-code snippet"><div class="inner"><pre>
<a href="http://www.allegro.cc/manual/drawing_mode" target="_blank"><span class="a">drawing_mode</span></a><span class="k2">(</span>DRAW_MODE_TRANS,NULL,<span class="n">0</span>,<span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
<span class="c">// the 128 on the following line is the translucency: 0 totally translucent, 255 fully black</span>
<a href="http://www.allegro.cc/manual/set_trans_blender" target="_blank"><span class="a">set_trans_blender</span></a><span class="k2">(</span><span class="n">0</span>,<span class="n">0</span>,<span class="n">0</span>,<span class="n">128</span><span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/putpixel" target="_blank"><span class="a">putpixel</span></a><span class="k2">(</span>target,x,y,<a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><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 class="k2">;</span>
<a href="http://www.allegro.cc/manual/solid_mode" target="_blank"><span class="a">solid_mode</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

... and of course, you shouldn&#39;t do this pixel by pixel - draw all translucent stuff before going back to &quot;normal&quot; mode with &quot;solid_mode()&quot; - or use rectfill, draw_trans_sprite or similar.</p><p>regarding your other question - its using an int because that is enough - you&#39;ll have enough room to store the data that is necessary - 8 bits for all the r,g and b, and also 8 bits for alpha channel. The authors of allegro <i>could</i> have made a struct or something similar of it though, but I think ints are used for simplicity (speed also might be a part of it.) </p><p>To get (for example) the red channel out of a pixel (an int) use the get_r / get_g / get_b functions. More in here: (<a href="http://www.allegro.cc/manual/api/truecolor-pixel-formats/">Truecolor pixel formats</a>)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bhagabhi)</author>
		<pubDate>Sat, 02 Dec 2006 17:56:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>thanks for the reply. i&#39;ve only got internet away from home at the moment so i&#39;m late replying. I&#39;ll try the code.<br /> Another question :- how is makeacol32() used ?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (William Labbett)</author>
		<pubDate>Sun, 03 Dec 2006 17:58:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I am not an expert on the alpha-drawing stuff - but my guess is that you make a 32-bit bitmap using create_bitmap_ex(32,width,height) - and then you can draw to it with putpixel (or other primitive drawing stuff) in combination with makeacol (to make regions of the bitmap somewhat translucent) , and then using draw_trans_sprite to draw the sprite(bitmap) to the screen/other bitmap.</p><p>(sorry for not linking the commands to the manual - I am sure you can find what you are after anyhow - in the online manual or the one that comes with the allegro package).</p><p>There should be people here that knows more about it than me though.</p><p>[edit]<br />Found some minor problems with the commenting on this page though:</p><p><a href="http://www.allegro.cc/manual/api/bitmap-objects/create_bitmap_ex">http://www.allegro.cc/manual/api/bitmap-objects/create_bitmap_ex</a></p><p>Looks like the same problem is in the manual in the allegro package too.<br />(reported to AD.)</p><p>[edit2] oops, no, I didn&#39;t mail - having problems mailing to alleg-devel... hope someone in charge sees  this then.[/edit2]</p><p>[/edit]
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bhagabhi)</author>
		<pubDate>Mon, 04 Dec 2006 01:34:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Allegro translucency support is severely lacking.  Support for it has pretty much stopped in favor of hardware accelerated libraries like OpenGL or Direct3D.</p><p>If you&#39;re looking for something actually useful with translucency, you&#39;re looking in the wrong place.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Mon, 04 Dec 2006 16:01:03 +0000</pubDate>
	</item>
</rss>
