<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Creating sub bitmap from display</title>
		<link>http://www.allegro.cc/forums/view/616651</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 23 Dec 2016 06:08:28 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hello guys,</p><p>I try to use the al_create_sub_bitmap from the my current display but it doesnt work. I constantly have that output:</p><p>Assertion failed: bitmap != dest &amp;&amp; bitmap != dest-&gt;parent, file C:\dev\allegro_winpkg\universal\allegro\src\bitmap_draw.c, line 34</p><p>The only I found to bypass this problem is to copy the full display in an another bitmap then make my saving from this saved bitmap. Here is my trick:</p><p>1) al_set_target_bitmap(save_bitmap)<br />2) al_draw_bitmap(display, 0, 0, 0);<br />3) al_set_target_bitmap(display);<br />4) al_create_sub_bitmap(save_bitmap, .....); </p><p>Could like to bypass all this and use al_create_sub_bitmap directly from display.</p><p>Any idea would be appreciated thank you <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (limprevisible)</author>
		<pubDate>Thu, 22 Dec 2016 05:41:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You could use <span class="source-code"><a href="http://www.allegro.cc/manual/al_draw_bitmap_region"><span class="a">al_draw_bitmap_region</span></a></span>. Why do you need a sub bitmap of the display? You can set a clipping rectangle as well if that&#39;s what you&#39;re worried about.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Thu, 22 Dec 2016 05:47:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I am creating a map with tiles.</p><p>Lets say that I have one tile representing the ground. The tile next to it will be the coast (composed by half part ground and the other one water). So what I do is:</p><p>1) Save half of the ground<br />2) Paste the ground on water<br />3) Paste the coast</p><p>So I will have at the end a tile composed by ground - coast - water.</p><p>So that&#39;s why I need to save a region of the display.</p><p>I will try the al_draw_bitmap_region and let you know <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p><p>=&gt; I tried with the al_draw_bitmap_region and still the same:</p><p>Assertion failed: bitmap != dest &amp;&amp; bitmap != dest-&gt;parent, file C:\dev\allegro_winpkg\universal\allegro\src\bitmap_draw.c, line 34
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (limprevisible)</author>
		<pubDate>Thu, 22 Dec 2016 06:17:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The way I solve this in my tile map engine is to draw the tile partially by applying a mask to the tile before drawing it. See here <a href="https://gitlab.com/beoran/eruta-bs/blob/master/src/tile.c#L508">https://gitlab.com/beoran/eruta-bs/blob/master/src/tile.c#L508</a> for how I do it. This is IMO easier than messing with the screen, and also gives better performance. On contemporary architectures, reading from the screen is slow.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (beoran)</author>
		<pubDate>Thu, 22 Dec 2016 21:10:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That assertion means that you can&#39;t draw a bitmap to itself, it&#39;s not specific to the display bitmap. The reason why that&#39;s forbidden is because, if I recall correctly, this operation isn&#39;t actually hardware accelerated. Basically you want to use an intermediate bitmap (there shouldn&#39;t be any speed penalty for this) and you should avoid reading from the display.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Thu, 22 Dec 2016 22:25:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You don&#39;t need the screen to do this. Do it on a buffer or temporary bitmaps instead.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Thu, 22 Dec 2016 23:32:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Indeed I tried with a temp bitmap and it worked totally fine. Pity that we cant copy directly from the display.</p><p>Thanks by the way guys.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (limprevisible)</author>
		<pubDate>Fri, 23 Dec 2016 05:07:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You <b>should</b> be able to copy from the display directly. Problem is you&#39;re reading data from the GPU and the memory has to be locked. You can&#39;t draw from the screen to the screen however, if that&#39;s what you&#39;re doing.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Fri, 23 Dec 2016 06:08:28 +0000</pubDate>
	</item>
</rss>
