<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>How does allegro load transparent background sprite images </title>
		<link>http://www.allegro.cc/forums/view/616940</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 13 Jun 2017 21:22:47 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hey guy&#39;s, so I solved the problem of loading a bitmap image, thanks to everyone who had helped me but then I came across a question to myself.</p><p>Why does sprites have a magenta color background when being used for allegro?<br />does it have something to do with the bit values</p><p>and if so, how do I make this sprite I made in gimp and edited with paint load or show up WITHOUT the white background? I will provide an attachment for you guys to look at (the &quot;kid.bmp&quot; image)</p><p>in my code I set the color depth to desktop_color_depth() to support my system, but why does it show the white background which was edited in paint?</p><p>How does it work with magenta?</p><p>more info: I&#39;m using a 32 bit machine which runs just fine, I&#39;ve also provided the output of the program when running.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (coderthatcancode)</author>
		<pubDate>Sun, 11 Jun 2017 18:31:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/616940/1030943#target">coderthatcancode</a> said:</div><div class="quote"><p> Why does sprites have a magenta color background when being used for allegro?</p></div></div><p>Allegro (at least Allegro 4) uses a magenta (often called &quot;magic pink&quot;) background for transparency because it is one of the most unlikely colors to appear naturally, making it a safe color to be removed. This is somewhat similar to how green screens work; when using a green screen, the idea is that the color green is so distant from the rest of the colors present on the actor or props in front of the screen that it makes it easy to remove the green background without also accidentally removing colors from the objects in front of it.</p><p>When saving kid.bmp, did it contain a white background? If so, then that background will still be present when used with Allegro. What you need to do is change the background to that magic pink color (255, 0, 255) instead.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Eric Johnson)</author>
		<pubDate>Sun, 11 Jun 2017 20:27:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>+Eric Johnson yeah, I did but then when I loaded it in allegro 4 it crashed with the magenta background so I had to open up paint and erase the magenta background. Do you think it has anything to do with my code? for setting the color depth I do set_color_depth(desktop_color_depth());
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (coderthatcancode)</author>
		<pubDate>Sun, 11 Jun 2017 23:15:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Interesting. I&#39;m not well-versed with Allegro 4, so I&#39;m not sure. If you suspect it may have something to do with the color depth, then try changing it and see if that corrects the issue.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Eric Johnson)</author>
		<pubDate>Mon, 12 Jun 2017 00:34:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/616940/1030949#target">coderthatcancode</a> said:</div><div class="quote"><p> Do you think it has anything to do with my code? for setting the color depth I do set_color_depth(desktop_color_depth());</p></div></div><p>That particular line is not going to cause your program to crash, but yes the problem is probably related to your code.  You&#39;ll need to post your code if you want help with it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (LennyLen)</author>
		<pubDate>Mon, 12 Jun 2017 01:48:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>@LennyLen Ok, I will provide the code. I&#39;m know allegro 4 and I only know how to write code in C (not C++). I only think it might have been the color depth because I&#39;m setting it to my desktops color scheme which I&#39;m not sure if that&#39;s the proper way to generate transparent backgrounds for sprite in allegro.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (coderthatcancode)</author>
		<pubDate>Mon, 12 Jun 2017 02:50:28 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Your program works fine for me with a bitmap I made to test it.  The problem is your bitmap. If you&#39;d bothered doing some error checking, this would have been obvious.</p><p>Also: learn to use a debugger.  It would have told you that the code is crashing at line 27, which is after setting the bit depth.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (LennyLen)</author>
		<pubDate>Mon, 12 Jun 2017 08:35:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>This looks a lot like your former issue, where you accidentally saved the modified image as GIF instead of BMP (despite having a .bmp file extension)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Audric)</author>
		<pubDate>Mon, 12 Jun 2017 13:13:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I just noticed that the bmp was attached to the original post.  I used it, and the program ran fine:</p><p><span class="remote-thumbnail"><span class="json">{"name":"610934","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/2\/429bd33f15eba8accc69efa4f229bcc9.png","w":656,"h":518,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/2\/429bd33f15eba8accc69efa4f229bcc9"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/4/2/429bd33f15eba8accc69efa4f229bcc9-240.jpg" alt="610934" width="240" height="189" /></span></p><p>My guess is that you don&#39;t have the bmp in the working directory.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (LennyLen)</author>
		<pubDate>Mon, 12 Jun 2017 17:45:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>@LennyLen I don&#39;t think you understand the problem, it wasn&#39;t anything to do with loading the bitmap or it being in the same directory, its the fact that I&#39;m trying to load a bitmap image with a transparent background rather than a white one as you can tell from the sprite, now some would say that I need to set it to magenta (the magic pink) which is what I did, and so that didn&#39;t work and it crashed when I put the magenta color in edited with GIMP 2. Then when I try edit it with paint it shows the magenta color in the background which hence why I&#39;ve asked: &quot;&quot;.</p><p>I will the attachments in this message.</p><p>1) The Output <br />2) The Image
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (coderthatcancode)</author>
		<pubDate>Mon, 12 Jun 2017 21:42:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The &#39;image&#39; you attached is a .jpg file - you can&#39;t load that without jpgalleg. Did you initialize the jpgalleg addon? You have to register .jpg files with allegro before you can load them or it will return a null pointer and then when you draw with it it will crash.</p><p>Post code.</p><p>You can also load pngs with loadpng, another Allegro 4 addon. But similarly, you have to register the png loader with allegro first.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Mon, 12 Jun 2017 22:18:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Nope, it is a bitmap The two image were image 50 which was a screen shot of my bitmap in paint and then there was the other one which is just how the program runs with the green background which is what I put as the overall background.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (coderthatcancode)</author>
		<pubDate>Tue, 13 Jun 2017 02:27:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Wait a minute.</p><p>Wait.</p><p>Open the original bitmap that works with GIMP again.</p><p>Modify anything in it like a pixel.</p><p>Save it.</p><p>Does Allegro crash?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Chris Katko)</author>
		<pubDate>Tue, 13 Jun 2017 03:14:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>We&#39;ve already told you several times now, some .bmp files are simply NOT compatible with Allegro 4. Get it? If you can save it from one program and it crashes, and you can save it from another program and it doesn&#39;t, then save it in the second program and move on with your life.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Tue, 13 Jun 2017 07:17:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>+Edgar dude, it&#39;s my own bitmap image of course it should work, and be compatible with allegro 4. I&#39;ve used the right .bmp extension when edited in paint (24-bit bitmap) </p><p>+Chris Katko That does crash because allegro doesn&#39;t support the gimps bitmap, I don&#39;t even know how to change that, even if it didn&#39;t crash it would still show the white background.</p><p>EDIT: THE PROBLEM HAS BEEN SOLVED BY USING:<br />draw_sprite(buffer, guy,guy_x, guy_y);</p><p>In case you didn&#39;t see the code I attached the code I wrote in the previous message.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (coderthatcancode)</author>
		<pubDate>Tue, 13 Jun 2017 20:52:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Paint the area you want transparent as hot pink (R = 255 , G = 0 , B = 255). Then save it with paint.</p><p>Then try this code :
</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span>
<span class="number">  2</span>
<span class="number">  3</span><span class="p">#include "allegro.h"</span>
<span class="number">  4</span>
<span class="number">  5</span>
<span class="number">  6</span><span class="k1">int</span> main<span class="k2">(</span><span class="k1">int</span> argc , <span class="k1">char</span><span class="k3">*</span><span class="k3">*</span> argv<span class="k2">)</span> <span class="k2">{</span>
<span class="number">  7</span>   
<span class="number">  8</span>   
<span class="number">  9</span>   <span class="k1">if</span> <span class="k2">(</span><a href="http://www.allegro.cc/manual/allegro_init"><span class="a">allegro_init</span></a><span class="k2">(</span><span class="k2">)</span> <span class="k3">!</span><span class="k3">=</span> <span class="n">0</span><span class="k2">)</span> <span class="k2">{</span><span class="k1">return</span> <span class="n">1</span><span class="k2">;</span><span class="k2">}</span>
<span class="number"> 10</span>   
<span class="number"> 11</span>   <a href="http://www.allegro.cc/manual/install_timer"><span class="a">install_timer</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 12</span>   <a href="http://www.allegro.cc/manual/install_keyboard"><span class="a">install_keyboard</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 13</span>   
<span class="number"> 14</span>   <a href="http://www.allegro.cc/manual/set_color_depth"><span class="a">set_color_depth</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/desktop_color_depth"><span class="a">desktop_color_depth</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 15</span>   
<span class="number"> 16</span>   <span class="k1">if</span> <span class="k2">(</span><a href="http://www.allegro.cc/manual/set_gfx_mode"><span class="a">set_gfx_mode</span></a><span class="k2">(</span>GFX_AUTODETECT_WINDOWED , <span class="n">400</span> , <span class="n">300</span> , <span class="n">0</span> , <span class="n">0</span><span class="k2">)</span> <span class="k3">!</span><span class="k3">=</span> <span class="n">0</span><span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 17</span>      <span class="k1">return</span> <span class="n">2</span><span class="k2">;</span>
<span class="number"> 18</span>   <span class="k2">}</span>
<span class="number"> 19</span>   
<span class="number"> 20</span>   <a href="http://www.allegro.cc/manual/BITMAP"><span class="a">BITMAP</span></a><span class="k3">*</span> spr <span class="k3">=</span> <a href="http://www.allegro.cc/manual/load_bitmap"><span class="a">load_bitmap</span></a><span class="k2">(</span><span class="s">"magic_pink.bmp"</span> , <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 21</span>   
<span class="number"> 22</span>   <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span>spr<span class="k2">)</span> <span class="k2">{</span><span class="k1">return</span> <span class="n">3</span><span class="k2">;</span><span class="k2">}</span>
<span class="number"> 23</span>   
<span class="number"> 24</span>   <a href="http://www.allegro.cc/manual/clear_to_color"><span class="a">clear_to_color</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/screen"><span class="a">screen</span></a> , <a href="http://www.allegro.cc/manual/makecol"><span class="a">makecol</span></a><span class="k2">(</span><span class="n">0</span> , <span class="n">255</span> , <span class="n">255</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 25</span>   
<span class="number"> 26</span>   <a href="http://www.allegro.cc/manual/draw_sprite"><span class="a">draw_sprite</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/screen"><span class="a">screen</span></a> , spr , <span class="n">0</span> , <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 27</span>   
<span class="number"> 28</span>   <a href="http://www.allegro.cc/manual/readkey"><span class="a">readkey</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 29</span>   
<span class="number"> 30</span>   <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span>
<span class="number"> 31</span><span class="k2">}</span>
<span class="number"> 32</span><a href="http://www.allegro.cc/manual/END_OF_MAIN"><span class="a">END_OF_MAIN</span></a><span class="k2">(</span><span class="k2">)</span>
</div></div><p>

If allegro&#39;s color depth is 8 bit, you will lose the magic pink. 8-bit is default if you don&#39;t set any color depth.</p><p><a href="https://www.allegro.cc/files/attachment/610939">magic_pink.zip</a></p><p>Try the program in the attached zip file. If it works for you, you&#39;re still doing something wrong. Show code again.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Tue, 13 Jun 2017 21:22:47 +0000</pubDate>
	</item>
</rss>
