<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>saving bitmap into memory instead of a file</title>
		<link>http://www.allegro.cc/forums/view/612339</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Wed, 03 Apr 2013 21:43:44 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hello,</p><p>so I have some bitmaps and I would like to save them to the disk. However this is done while the game is running (autosave) and slows the game quite a lot (most of the time is burned in the IO). Therefore I spawn a secondary thread to save the bitmaps to the drive. The thread can&#39;t operate bitmaps as rich allegro data (because OSX doesn&#39;t like that) so I would need to pass the bitmpas as raw memory to the thread. Ideally as stringstreams or something.</p><p>So my question is when I have an allegro bitmap how do I dump it to a memory ?</p><p>This is probably quite silly. However I have played with ALLEGRO_FILE for a while and haven&#39;t figured out how to create one mapped to memory with appropriate size. Thanks for the help.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (sleepywind)</author>
		<pubDate>Wed, 03 Apr 2013 13:14:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Take a look at the memfile addon and <span class="source-code"><a href="http://www.allegro.cc/manual/al_save_bitmap_f"><span class="a">al_save_bitmap_f</span></a></span>.</p><p>The memfile addon doesn&#39;t support dynamic sizing (which isn&#39;t TOO hard to implement, it just hasn&#39;t been a priority), so you&#39;ll have to create it with a large enough buffer.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Wed, 03 Apr 2013 13:31:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah I figured I could create ALLEGRO_FILE via al_open_memfile and then use the al_save_bitmap_f. However is there a way to figure out how big buffer to allocate for a given bitmap ? I searched the bitmap interface and hasn&#39;t found anything. Of course I can make some &quot;good enough&quot; estimates by taking the width and height and multipliing that by 4bytes or so, but I would prefer no to guess <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (sleepywind)</author>
		<pubDate>Wed, 03 Apr 2013 16:11:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That&#39;s a pretty good guess if you&#39;re saving a non-compressed bitmap, you may actually want to make it a bit larger than that. If you&#39;re saving it in a compressed form like jpeg or png, that guess should almost always work, since parts of the bitmap will almost always be compressed.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Wed, 03 Apr 2013 21:43:44 +0000</pubDate>
	</item>
</rss>
