<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>How to get a pointer to every pixel on bitmap?</title>
		<link>http://www.allegro.cc/forums/view/618426</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 03 Jun 2021 23:07:01 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I solved my problem. The pitch was actually negative, I didn&#39;t noticed that at first.<br />Hi, I&#39;m doing uni project using allegro library. I&#39;m using c++.<br />I load an image onto the screen, and I would like to modify each pixel individually. I lock the bitmap region. After that I call the method:<br />locked_reg = al_lock_bitmap(bitmapPointer, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_READWRITE);<br />Then I get a pointer to the pixel data like so:<br />void* data1 = (locked_reg-&gt;data);<br />But according to the documentation, that gives me only array of pixels in the first row! <a href="https://www.allegro.cc/manual/5/ALLEGRO_LOCKED_REGION">https://www.allegro.cc/manual/5/ALLEGRO_LOCKED_REGION</a>. <br />And this is true, when I modify each pixel I get access only to the first row.<br />Is there a way to get an array with all the pixels on the bitmap in a way that I can modify it?</p><p>According to this thread: <a href="https://www.allegro.cc/forums/thread/616922">https://www.allegro.cc/forums/thread/616922</a> (Edgar Reynaldo - Posted on 05/31/2017 4:44 PM):<br />The coordinate of the pixel should be: locked_reg-&gt;data + x * locked_reg-&gt;pixel_size + region-&gt;pitch * y.</p><p>Okay nevermind, the pitch was negative. It works now <img src="http://www.allegro.cc/forums/smileys/cool.gif" alt="8-)" /></p><p>Thanks for help
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (fuspepro)</author>
		<pubDate>Wed, 02 Jun 2021 04:27:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Glad you solved it. The manual can be very helpful, make sure to make good use of it.</p><p><a href="https://liballeg.org/a5docs/trunk/graphics.html#al_lock_bitmap">https://liballeg.org/a5docs/trunk/graphics.html#al_lock_bitmap</a><br /><a href="https://liballeg.org/a5docs/trunk/graphics.html#allegro_locked_region">https://liballeg.org/a5docs/trunk/graphics.html#allegro_locked_region</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Thu, 03 Jun 2021 23:07:01 +0000</pubDate>
	</item>
</rss>
