<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Allegro 5 - bitmap editing</title>
		<link>http://www.allegro.cc/forums/view/603036</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 05 Feb 2010 16:19:13 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m making a program that manipulates the color channels of a bitmap separately. So I can paint on more red without changing any green, blue or alpha for example.</p><p>Here&#39;s code for painting on more red using the filled circle primitive.</p><div class="source-code snippet"><div class="inner"><pre>al_set_target_bitmap<span class="k2">(</span>my_bitmap<span class="k2">)</span><span class="k2">;</span>
al_set_blender<span class="k2">(</span>allegro5.color.ONE, allegro5.color.ONE, al_map_rgba_f<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="k2">)</span><span class="k2">;</span>

allegro5.primitives.draw_filled_circle<span class="k2">(</span>x, y, <span class="n">10</span>, al_map_rgba_f<span class="k2">(</span><span class="n">0</span>.<span class="n">2</span>, <span class="n">0</span>, <span class="n">0</span>, <span class="n">1</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>

al_set_current_display<span class="k2">(</span>my_display<span class="k2">)</span><span class="k2">;</span>
set_blender<span class="k2">(</span>allegro5.color.ALPHA, allegro5.color.INVERSE_ALPHA, map_rgba_f<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="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

My problem now is that I wanna be able to reduce the amount of red too. But it seems there&#39;s only funcionality in place to let me add color.<br />Is there a way to erase some red from the bitmap?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trezker)</author>
		<pubDate>Wed, 03 Feb 2010 18:01:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Since OpenGL and D3D don&#39;t have subtractive blending without extensions, neither does Allegro. You&#39;ll have to find another way.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Wed, 03 Feb 2010 18:13:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;ve been thinking about it, and can&#39;t find a way.</p><p>What extensions are you talking about?<br />And does anyone have a different solution?</p><p>EDIT: I do know it&#39;s possible to blend in a darker color over something brighter. But the regular way to do that is by using the alpha channel for translucency and that means it will pull down r, g and b.</p><p>I just wish I could do that but only affect one color channel. :/
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trezker)</author>
		<pubDate>Thu, 04 Feb 2010 11:25:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If I understand you correctly, using <span class="source-code">glColorMask</span> will do the trick under OpenGL. While I&#39;m sure this is also possible to do in D3D, this sort of function is unlikely to show up in Allegro itself since it&#39;d require changing a megaton of code.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Thu, 04 Feb 2010 21:27:13 +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/603036/849816#target">Trezker</a> said:</div><div class="quote"><p>
I wanna be able to <b>reduce</b> the amount of red too
</p></div></div><p>
(Emphasis mine)</p><p>glColorMask() turns a particular RGBA element off entirely
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Thu, 04 Feb 2010 21:30:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I was thinking of masking off the green/blue channels and writing a new colour to the red channel... but I guess the reduction was meant more in the subtractive sense, than the setting to a lesser value sense I took it in <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /></p><p>Nevermind then. Use a shader.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Thu, 04 Feb 2010 21:45:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;ll take a look on colormask, maybe it can solve the problem. At least enough to meet my needs.</p><p>As for the shader route, I looked into that and it turns out blending takes place after your shader. So the blending stage isn&#39;t programmable and I&#39;ve seen conflicting opinions about the readability of the rendering target which I think is required if I want to blend incoming fragments with what&#39;s previously on the target.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trezker)</author>
		<pubDate>Thu, 04 Feb 2010 22:47:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I guess Allegro 5 doesn&#39;t have get/putpixel.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Felix-The-Ghost)</author>
		<pubDate>Thu, 04 Feb 2010 23:57:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The rendering target should always be readable in a shader, AFAIK... what good would they be if not? So instead of doing the blending stage, you do your blending in the shader. Luckily they&#39;re very fast.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Fri, 05 Feb 2010 00:04: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/603036/849946#target">Felix-The-Ghost</a> said:</div><div class="quote"><p>I guess Allegro 5 doesn&#39;t have get/putpixel.</p></div></div><p>
Sure it does:<br /><a href="http://alleg.sourceforge.net/a5docs/refman/graphics.html#al_get_pixel">http://alleg.sourceforge.net/a5docs/refman/graphics.html#al_get_pixel</a><br /><a href="http://alleg.sourceforge.net/a5docs/refman/graphics.html#al_put_pixel">http://alleg.sourceforge.net/a5docs/refman/graphics.html#al_put_pixel</a><br /><a href="http://alleg.sourceforge.net/a5docs/refman/graphics.html#al_draw_pixel">http://alleg.sourceforge.net/a5docs/refman/graphics.html#al_draw_pixel</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Fri, 05 Feb 2010 00:04:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>so...he should make a blender function himself with it.<br /><img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p><p>I guess I can assume it has the getr/getg/getb and rgb_to_hsv etc.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Felix-The-Ghost)</author>
		<pubDate>Fri, 05 Feb 2010 00:11:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That&#39;s an awful slow way to do it. The get/put pixel functions are a bit slower than in 4.4. This is what shaders are meant for.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Fri, 05 Feb 2010 00:14:11 +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/603036/849955#target">Felix-The-Ghost</a> said:</div><div class="quote"><p>I guess I can assume it has the getr/getg/getb and rgb_to_hsv etc.</p></div></div><p>
Don&#39;t guess, just read the manual.</p><p>Anyway, yes, you probably can do it that way. But it doesn&#39;t play nice with the hardware, as Trent said. It&#39;s the Allegro 4 way of doing things, but Allegro 5 is (will be) a different thing entirely.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Fri, 05 Feb 2010 00:55:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The reasons for not bringing up getpixel/putpixel functions are these:<br />I fear it&#39;s rather slow. (minor reason, I could maybe live with it)<br />I&#39;d have to code my own primitives rendering.<br />I was already aware of this approach and felt it was such an obvious option we don&#39;t even need to discuss it.</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/603036/849950#target">Trent Gamblin</a> said:</div><div class="quote"><p>
The rendering target should always be readable in a shader, AFAIK... what good would they be if not? So instead of doing the blending stage, you do your blending in the shader. Luckily they&#39;re very fast.
</p></div></div><p>

Having the rendering target available from shader is not at all an obvious feature. The incoming graphics in almost all situations has no need to know what&#39;s already been rendered. The shaders purpose is to determine how lighting and colors are handled on the current fragment without any consideration to what else is in the scene.</p><p>The fixed shader that you get in opengl sucks actually. For example, it barely handles specular so you get a diamond shaped lighting around vertices that get affected by specular. Just by coding a very basic shader you get much smoother shading.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trezker)</author>
		<pubDate>Fri, 05 Feb 2010 11:33:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Maybe you could glCopyPixels to/from a memory buffer and fiddle with the red component on your own.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Fri, 05 Feb 2010 11:36:23 +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/603036/849985#target">Trezker</a> said:</div><div class="quote"><p>The shaders purpose is to determine how lighting and colors are handled on the current fragment without any consideration to what else is in the scene.</p></div></div><p>How is that supposed to be able to handle blending, shadows and whatnot? Without knowing what is already there, you can&#39;t do any real fancy effects.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Fri, 05 Feb 2010 11:43:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If you&#39;re doing all that, aren&#39;t you using lighting?  Just change the lights...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Fri, 05 Feb 2010 11:46:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The shader doesn&#39;t do blending, blending takes place in a later stage that&#39;s not programmable.</p><p>I don&#39;t know much about shadows, it&#39;s something about stencils and stuff.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trezker)</author>
		<pubDate>Fri, 05 Feb 2010 12:33:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Uh, why can&#39;t you do blending in a shader? I thought that was most of the reason for shaders. To implement awesome things that the fixed function stuff couldn&#39;t even dream of.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Fri, 05 Feb 2010 12:46:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Trekzer, you&#39;re just trying to draw primitives in a window like MS-Paint?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Fri, 05 Feb 2010 12:50:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>No I&#39;m working on a heightmap editor. The heightmap uses the color channels of one texture (splat texture) to blend four different textures. (This is different blending, I&#39;m not blending with the target, only the textures which are used for the fragment that comes into the shader)</p><p>So for the editor, I al_set_target_bitmap(splat_texture) and paint the color channels, which makes it look like I&#39;m painting textures onto my heightmap.</p><p>Anyway, I&#39;ve tried glColorMask now and it works perfectly. At least rgb works just as I want, now I just need to figure out how to paint the alpha channel.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trezker)</author>
		<pubDate>Fri, 05 Feb 2010 13:49:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That&#39;s <i>way</i> beyond any bitmap-based heightmap I&#39;ve ever done.  I just used the int as a height so viewing the &quot;image&quot; would resemble a contour map.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Fri, 05 Feb 2010 13:53:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The heights aren&#39;t controlled by any bitmap, only the texturing of it.<br />Here&#39;s an explanation.<br /><a href="http://www.gamedev.net/reference/articles/article2238.asp">http://www.gamedev.net/reference/articles/article2238.asp</a></p><p>For the height points I&#39;m just using arrays now, haven&#39;t even gotten around to saving it to any file format.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trezker)</author>
		<pubDate>Fri, 05 Feb 2010 16:19:13 +0000</pubDate>
	</item>
</rss>
