<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>al_get_pixel performance</title>
		<link>http://www.allegro.cc/forums/view/610635</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 31 Jul 2012 04:53:38 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I was aware that al_get_pixel would be slow on video bitmaps, but I&#39;m getting approximately on the order of 100 pixels per second? Is this normal? This is under linux with intel chip and the open source driver, this system is very new.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Alianix)</author>
		<pubDate>Mon, 16 Jul 2012 09:52:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Are you locking the bitmap?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Mon, 16 Jul 2012 09:56:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It is <i>incredibly</i> slow on video bitmaps. Allegro has to pretty much download the entire texture to get your pixel. for every pixel. Try wrapping your <span class="source-code">al_get_pixels</span> in a <span class="source-code"><a href="http://www.allegro.cc/manual/al_lock_bitmap"><span class="a">al_lock_bitmap</span></a></span> call. Or you can access the locked pixel data directly if you wish. may be a bit faster than calling <span class="source-code"><a href="http://www.allegro.cc/manual/al_get_pixel"><span class="a">al_get_pixel</span></a></span> a load of times.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 16 Jul 2012 09:59:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks guys, I really haven&#39;t looked into optimizing this part of my code but it looks like now is the time. I really need a fast routine in the end, I will try your suggestions first, (and no I was not locking the bitmaps) but I was thinking of keeping a memory bitmap copy of these bitmaps when using al_get_pixel. Would you say this is the best approach?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Alianix)</author>
		<pubDate>Mon, 16 Jul 2012 10:06:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If you can spare the memory, yes.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Mon, 16 Jul 2012 10:14:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Locking the bitmap gave a lot better performance about 100x faster, I still think it could be done faster.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Alianix)</author>
		<pubDate>Mon, 16 Jul 2012 10:21:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Are you still using <span class="source-code"><a href="http://www.allegro.cc/manual/al_get_pixel"><span class="a">al_get_pixel</span></a><span class="k2">(</span><span class="k2">)</span></span>? You can also access the raw data directly. Pay attention to the locking pixel format if you do that.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Mon, 16 Jul 2012 10:24:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;d say first try circumventing <span class="source-code"><a href="http://www.allegro.cc/manual/al_get_pixel"><span class="a">al_get_pixel</span></a></span> and access the downloaded data directly, and if that&#39;s not fast enough utilize the extra memory with a RAM copy. What exactly are you using this for, anyway? If you&#39;re testing for pixel existence instead of value, you can store the RAM copy as a literal bit map (one bit per pixel) and use some nice &amp;, &lt;&lt; and &gt;&gt; operators to get some nice, memory efficient and speedy checks.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Luiji99)</author>
		<pubDate>Mon, 16 Jul 2012 10:28:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I need to map the video bitmap to an actual memory &quot;bitmap&quot; so i need to scan the entire bitmap for pixel values. It is only necessary to do this once and i can save the bitmap to disk also easily. The locking works ok for now i will improve the mapping function later by using allegro memory bitmaps.</p><p>Update...</p><p>Done some more testing and it looks like using memory bitmaps is a bit faster then video bitmaps but still too slow. I don&#39;t see how to portably read pixels directly as I&#39;m not sure how pixels are mapped. Can I trust that the pixel values will stay the same across platforms? Looks like now the only safe resort is to save the maps to a file and read it back, but then I have to worry about compression...Any ideas here?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Alianix)</author>
		<pubDate>Mon, 16 Jul 2012 19:35:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi,</p><p>I had initially written old code for Allegro 4 using getpixel. When going to A5, I saw that the code which used to run in 40ms now took a minute on video bitmaps. All that changed when I implemented my own pixel shader in Allegro 5.1... I guess getting values to-fro video memory is not a good idea for pixel processing.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (guilt)</author>
		<pubDate>Tue, 31 Jul 2012 04:03:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Try <span class="source-code"><a href="http://www.allegro.cc/manual/al_lock_bitmap"><span class="a">al_lock_bitmap</span></a></span>.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Luiji99)</author>
		<pubDate>Tue, 31 Jul 2012 04:53:38 +0000</pubDate>
	</item>
</rss>
