<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Direct access to a pointer to bitmap</title>
		<link>http://www.allegro.cc/forums/view/616922</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 02 Jun 2017 00:14:49 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hey guys!<br />First post here, hello everyone <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /><br />I recently started using Allegro 5, i need to access the pixel table of loaded BMP file.I know you could do it with Allegro 4 by line parameter, is there a way to do that in Allegro 5?<br />Thanks in advance <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kajkacz)</author>
		<pubDate>Wed, 31 May 2017 19:37:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There is <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> to read from graphic memory.<br />If you need something fast and/or you also want to write, please explain what you need it for.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Audric)</author>
		<pubDate>Wed, 31 May 2017 19:49:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If you don&#39;t use a memory bitmap, your data resides on the GPU side of things. Therefore, you should use bitmap locking, as reading / writing from/to the GPU is slow to do per-pixel. What it does is to cache (parts of) the bitmap in memory (CPU side of things). From there, you can also access the data directly via the ALLEGRO_LOCKED_REGION.</p><p>See <span class="source-code"><a href="http://www.allegro.cc/manual/al_lock_bitmap"><span class="a">al_lock_bitmap</span></a></span>, <span class="source-code"><a href="http://www.allegro.cc/manual/al_unlock_bitmap"><span class="a">al_unlock_bitmap</span></a></span> and <span class="source-code"><a href="http://www.allegro.cc/manual/ALLEGRO_LOCKED_REGION"><span class="a">ALLEGRO_LOCKED_REGION</span></a></span>.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Polybios)</author>
		<pubDate>Wed, 31 May 2017 21:39:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Related question: </p><p>What would be the fastest way to get array-level access to memory? I want to basically compare every single pixel on a bitmap structure. I was just trying this last week and noticed everything is in floats... if I could use integer comparisons that&#39;d be probably a thousand times faster. Are the al_unmap_rgb/al_get_pixel functions all doing various checks and color space conversions? All I want is read access to values.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Chris Katko)</author>
		<pubDate>Wed, 31 May 2017 22:52:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>In theory, the fastest way would probably be to do it directly on the GPU in parallel.<br /> <br />In practice when using Allegro, you can request a certain pixel format (typically ALLEGRO_PIXEL_FORMAT_ABGR_8888) when locking and then just access it via the data pointer of the ALLEGRO_LOCKED_REGION al_lock_bitmap returns. Allegro will convert it for you when necessary.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Polybios)</author>
		<pubDate>Wed, 31 May 2017 23:07:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Audric, I am doing a school project where we have to use a mix of C and intel assembler.So I need to pass to the assembler function a pointer to the beggining of a pixel array.I will than use it to do the affine transforms
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kajkacz)</author>
		<pubDate>Thu, 01 Jun 2017 00:04:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Allegro 5 will give you access to a memory copy of the video memory. That&#39;s what happens when you lock a video bitmap. An <a href="http://liballeg.org/a5docs/trunk/graphics.html#allegro_locked_region">ALLEGRO_LOCKED_REGION</a> has a pointer to the data, a format, a pitch, and a pixel size. You use these to read and write the data.</p><p>Don&#39;t assume pitch is equivalent to pixel size times line width. It may differ, it may be different, or it may be negative.</p><p>You probably want to lock the region in a 24 or 32 bit format. Allegro will convert the bitmap to and from the format you lock it in.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Thu, 01 Jun 2017 02:44:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>In case the docs don&#39;t make it clear, &quot;pitch&quot; lets you know how to access lines after the first. Edgar refers to how lines can have padding between them (for memory alignment), or be arranged top to bottom.<br />In every case, the data of a given pixel will be at memory address: <span class="source-code">region-&gt;data <span class="k3">+</span> x <span class="k3">*</span> region-&gt;pixel_size <span class="k3">+</span> region-&gt;pitch <span class="k3">*</span> y</span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Audric)</author>
		<pubDate>Thu, 01 Jun 2017 14:31:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>@Kajkacz: <br />So you are writing / have to write a software renderer?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Polybios)</author>
		<pubDate>Fri, 02 Jun 2017 00:14:49 +0000</pubDate>
	</item>
</rss>
