<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Fast video frame drawing?</title>
		<link>http://www.allegro.cc/forums/view/607426</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 26 May 2011 16:23:24 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi!</p><p>I have problems to implement fast live-view from attached camera using Allegro 5. The camera streams uncompress color or grayscale images and I need to draw them inside my Allegro created fullscreen interface.</p><p>The problem is how to get frame data into bitmaps. When I use locking and filling the buffer with raw data, it is extremely slow and on a subpar graphics card (Intel 3150) I can get only about 15 FPS for 1024x768 images.</p><p>Surprisingly, when I wrote GDI application which uses SetDIBitsToDevice(), I could easily achieve 60 FPS at the same hardware. Why?</p><p>I would like to try to create offscreen bitmap, get a GDI drawing context for it and use the SetDIBitsToDevice(), but I do not know how. I found some examples for it, but these were for Allegro 4.</p><p>Thanks for help!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Freemanix)</author>
		<pubDate>Tue, 24 May 2011 17:02:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Try using a video bitmap that is the same size as your stream buffer, and lock it in WRITE_ONLY mode. That may speed things up some for you.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Tue, 24 May 2011 21:26:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That&#39;s exactly what I am doing. It is slow.</p><p>Is there a way how to get HDC from ALLEGRO_BITMAP? There was such a method in Allegro 4.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Freemanix)</author>
		<pubDate>Tue, 24 May 2011 22:46:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Okay then, what if you use a memory bitmap buffer and then draw it to the backbuffer? Is that any faster? Are you also locking the bitmap in the same format as the bitmap?</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/607426/918794#target">Freemanix</a> said:</div><div class="quote"><p>
Is there a way how to get HDC from ALLEGRO_BITMAP? There was such a method in Allegro 4.
</p></div></div><p>
Looks like the best you can get for now is <span class="source-code"><a href="http://www.allegro.cc/manual/al_get_d3d_video_texture"><span class="a">al_get_d3d_video_texture</span></a></span>. Allegro 4 only let you blit to and from an HDC, not create a new one.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Wed, 25 May 2011 02:36:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Actually, I solved this by creating my own Direct3D texture with D3DUSAGE_DYNAMIC in D3DPOOL_DEFAULT. Locking such a texture is about 10x faster than locking the ALLEGRO_BITMAP whichever way it was created.</p><p>Of course, I had to supply my own Direct3D drawing from that texture using DrawPrimitiveUP() call, but it was worth it. Now I just hope that my D3D drawing works seamlessly with the rest of Allegro5.</p><p>I would suggest Allegro5 should add new bitmap flag indicating that the bitmap being created is dynamic or suitable for streaming. I guess SDL 1.3.x have such flag already.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Freemanix)</author>
		<pubDate>Thu, 26 May 2011 16:23:24 +0000</pubDate>
	</item>
</rss>
