<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Who can tell me how to show the transparent  sprite?</title>
		<link>http://www.allegro.cc/forums/view/587580</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sat, 16 Sep 2006 22:11:02 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The sprite bitmap has a PINK(255,0,255) bg color, and my backbuff is black,<br />I want that when the sprite is drawn onto the backbuff, his bg color becomes BLACK color. what should I do ? my code doesn&#39;t work at all. look:
</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="p">#include &lt;allegro.h&gt;</span></td></tr><tr><td class="number">2</td><td><span class="p">#include "haphi.h"</span></td></tr><tr><td class="number">3</td><td>&#160;</td></tr><tr><td class="number">4</td><td><span class="k1">int</span> main<span class="k2">(</span><span class="k1">void</span><span class="k2">)</span></td></tr><tr><td class="number">5</td><td><span class="k2">{</span></td></tr><tr><td class="number">6</td><td>  <a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a><span class="k3">*</span> backbuff<span class="k2">;</span></td></tr><tr><td class="number">7</td><td>  <a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a><span class="k3">*</span> sprite<span class="k2">;</span></td></tr><tr><td class="number">8</td><td>  <a href="http://www.allegro.cc/manual/DATAFILE" target="_blank"><span class="a">DATAFILE</span></a><span class="k3">*</span> data<span class="k2">;</span></td></tr><tr><td class="number">9</td><td>  <a href="http://www.allegro.cc/manual/allegro_init" target="_blank"><span class="a">allegro_init</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">10</td><td>  <a href="http://www.allegro.cc/manual/install_keyboard" target="_blank"><span class="a">install_keyboard</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">11</td><td>  <a href="http://www.allegro.cc/manual/install_timer" target="_blank"><span class="a">install_timer</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">12</td><td>  <a href="http://www.allegro.cc/manual/set_color_depth" target="_blank"><span class="a">set_color_depth</span></a><span class="k2">(</span><span class="n">24</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">13</td><td>  <a href="http://www.allegro.cc/manual/set_gfx_mode" target="_blank"><span class="a">set_gfx_mode</span></a><span class="k2">(</span>GFX_AUTODETECT_WINDOWED, <span class="n">800</span>, <span class="n">600</span>, <span class="n">0</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">14</td><td>  backbuff <span class="k3">=</span> <a href="http://www.allegro.cc/manual/create_bitmap" target="_blank"><span class="a">create_bitmap</span></a><span class="k2">(</span><span class="n">800</span>, <span class="n">600</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">15</td><td>  <a href="http://www.allegro.cc/manual/clear_to_color" target="_blank"><span class="a">clear_to_color</span></a><span class="k2">(</span>backbuff, <a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><span class="k2">(</span><span class="n">0</span>,<span class="n">0</span>,<span class="n">0</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">16</td><td>  data <span class="k3">=</span> <a href="http://www.allegro.cc/manual/load_datafile" target="_blank"><span class="a">load_datafile</span></a><span class="k2">(</span><span class="s">"haphi.dat"</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">17</td><td>  sprite <span class="k3">=</span> <span class="k2">(</span><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a><span class="k3">*</span><span class="k2">)</span>data<span class="k2">[</span>WALK_RIGHT<span class="k2">]</span>.dat<span class="k2">;</span></td></tr><tr><td class="number">18</td><td>  <a href="http://www.allegro.cc/manual/masked_blit" target="_blank"><span class="a">masked_blit</span></a><span class="k2">(</span>sprite, backbuff, <span class="n">0</span>, <span class="n">0</span>, <span class="n">200</span>, <span class="n">300</span>, sprite-&gt;w, sprite-&gt;h<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">19</td><td>  <a href="http://www.allegro.cc/manual/blit" target="_blank"><span class="a">blit</span></a><span class="k2">(</span>backbuff, <a href="http://www.allegro.cc/manual/screen" target="_blank"><span class="a">screen</span></a>, <span class="n">0</span>, <span class="n">0</span>, <span class="n">0</span>, <span class="n">0</span>, <a href="http://www.allegro.cc/manual/SCREEN_W" target="_blank"><span class="a">SCREEN_W</span></a>, <a href="http://www.allegro.cc/manual/SCREEN_H" target="_blank"><span class="a">SCREEN_H</span></a><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">20</td><td>  <span class="k1">while</span><span class="k2">(</span><span class="k3">!</span><a href="http://www.allegro.cc/manual/key" target="_blank"><span class="a">key</span></a><span class="k2">[</span>KEY_SPACE<span class="k2">]</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">21</td><td>  <a href="http://www.allegro.cc/manual/unload_datafile" target="_blank"><span class="a">unload_datafile</span></a><span class="k2">(</span>data<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">22</td><td>  <a href="http://www.allegro.cc/manual/destroy_bitmap" target="_blank"><span class="a">destroy_bitmap</span></a><span class="k2">(</span>backbuff<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">23</td><td>  <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span></td></tr><tr><td class="number">24</td><td><span class="k2">}</span></td></tr><tr><td class="number">25</td><td><a href="http://www.allegro.cc/manual/END_OF_MAIN" target="_blank"><span class="a">END_OF_MAIN</span></a><span class="k2">(</span><span class="k2">)</span></td></tr></tbody></table></div></div><p>
<span class="remote-thumbnail"><span class="json">{"name":"590180","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/b\/4b5f5600e6c03aac9563b9e15118a76a.jpg","w":252,"h":250,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/b\/4b5f5600e6c03aac9563b9e15118a76a"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/4/b/4b5f5600e6c03aac9563b9e15118a76a-240.jpg" alt="590180" width="240" height="238" /></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (sj971059)</author>
		<pubDate>Sat, 16 Sep 2006 14:19:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It doesn&#39;t work because you saved the image as a JPEG, which compresses colors, and only the magic pink (255, 0, 255) is transparent in allegro... or black in 8 bpp.</p><p>At least that&#39;s how it looks on the screenshot.</p><p>Save the image as either a bmp or a png, and it should work fine.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CursedTyrant)</author>
		<pubDate>Sat, 16 Sep 2006 14:46:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>NO, the image in the post is just my screen-save, in my program, the sprite image <br />is indeed a BMP file stored in a *.dat file.<br />I use this to get it: BITMAP* sprite = (BITMAP*)data[WALK_RIGHT].dat;<br />I have used masked_blit(), but it still doesn&#39;t work.:-/ </p><p>Download attachment..my dat resource file in it. thanks.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (sj971059)</author>
		<pubDate>Sat, 16 Sep 2006 14:52:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
The sprite bitmap has a PINK(255,0,255) bg color
</p></div></div><p>

Nope.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Inphernic)</author>
		<pubDate>Sat, 16 Sep 2006 15:06:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I don&#39;t think I have the grabber atm, but I can see that it&#39;s not pure magic pink, because the top of the image is black, and the rest is not. Did you convert the sprite from a jpg or gif, perhaps?</p><p>In that case, a solution would be to use MS Paint and paint the background again (preferably using the erase tool).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CursedTyrant)</author>
		<pubDate>Sat, 16 Sep 2006 15:16:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Just Now , I use photoshop7.0 to check the BMP file RGB value and found that some area is (252,2,252) ,some area is (255,0,255), OH, my god......<br />I got these resource files from internet, after that , I clipped them and added them into a *.dat file, I think I broke their original quality. so that&#39;s why the top of the sprite&#39;s background color is BLACK, it puzzled me quite a while....
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (sj971059)</author>
		<pubDate>Sat, 16 Sep 2006 15:21:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Don&#39;t use antialiasing.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Paul whoknows)</author>
		<pubDate>Sat, 16 Sep 2006 22:11:02 +0000</pubDate>
	</item>
</rss>
