# More blitting trouble

**URL:** <https://discourse.libsdl.org/t/more-blitting-trouble/19716>\
**Category:** SDL Development\
**Created:** [July 2, 2013, 8:27pm UTC](https://discourse.libsdl.org/t/more-blitting-trouble/19716 "2013-07-02T20:27:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mason\_Wheeler](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/m/b9bd4f/32.png) [@Mason\_Wheeler](https://discourse.libsdl.org/u/Mason_Wheeler)\
**Post date:** [July 2, 2013, 8:27pm UTC](https://discourse.libsdl.org/t/more-blitting-trouble/19716/1 "2013-07-02T20:27:34Z")

</div>

This just keeps getting weirder.

I’ve got two images (attached), and I’m trying to composite them.? The bottom one is an 8-bit PNG, and the top is a 32-bit PNG with an alpha channel that includes a fully-transparent region.

I load both into surfaces with IMG\_Load. So far, so good.? Then I create a new SDL\_Surface to hold the output.? I blit Bottom onto it, and then Top, and save to PNG.? I expect to see the top image overlaid on the bottom one.

Instead, what I see depends on the output surface, but either way it’s wrong.? If I make the output surface 8-bit, the result is full of garbage, and if I make it 32-bit, the result is all black.

Any idea what’s going on here?? Running SDL2, HG revision 7309 (pretty darn recent) on Windows 7.

Mason  
-------------- next part --------------  
A non-text attachment was scrubbed…  
Name: top.png  
Type: image/png  
Size: 2897 bytes  
Desc: not available  
URL: [http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20130702/0838cf7e/attachment.png](http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20130702/0838cf7e/attachment.png)  
-------------- next part --------------  
A non-text attachment was scrubbed…  
Name: bottom.png  
Type: image/png  
Size: 1949 bytes  
Desc: not available  
URL: [http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20130702/0838cf7e/attachment-0001.png](http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20130702/0838cf7e/attachment-0001.png)

---

<div class="post-metadata">

**Author:** ![Mason\_Wheeler](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/m/b9bd4f/32.png) [@Mason\_Wheeler](https://discourse.libsdl.org/u/Mason_Wheeler)\
**Post date:** [July 2, 2013, 8:34pm UTC](https://discourse.libsdl.org/t/more-blitting-trouble/19716/2 "2013-07-02T20:34:17Z")

</div>

Argh. Just noticed the Bottom image was the wrong size.? (Trying to simulate something a lot more complicated going on inside the program.)? Here’s a better version.\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
From: Mason Wheeler \<@Mason\_Wheeler\>  
To: sdl   
Sent: Tuesday, July 2, 2013 1:27 PM  
Subject: [SDL] More blitting trouble

This just keeps getting weirder.

I’ve got two images (attached), and I’m trying to composite them.? The bottom one is an 8-bit PNG, and the top is a 32-bit PNG with an alpha channel that includes a fully-transparent region.

I load both into surfaces with IMG\_Load. So far, so good.? Then I create a new SDL\_Surface to hold the output.? I blit Bottom onto it, and then Top, and save to PNG.? I expect to see the top image overlaid on the bottom one.

Instead, what I see depends on the output surface, but either way it’s wrong.? If I make the output surface 8-bit, the result is full of garbage, and if I make it 32-bit, the result is all black.

Any idea what’s going on here?? Running SDL2, HG revision 7309 (pretty darn recent) on Windows 7.

Mason

* * *

SDL mailing list  
SDL at [lists.libsdl.org](http://lists.libsdl.org)  
[http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)  
-------------- next part --------------  
A non-text attachment was scrubbed…  
Name: bottom.png  
Type: image/png  
Size: 1968 bytes  
Desc: not available  
URL: [http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20130702/27968c73/attachment.png](http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20130702/27968c73/attachment.png)

---

<div class="post-metadata">

**Author:** ![slouken](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/ec9cab/32.png) [@slouken](https://discourse.libsdl.org/u/slouken)\
**Post date:** [July 4, 2013, 3:36pm UTC](https://discourse.libsdl.org/t/more-blitting-trouble/19716/3 "2013-07-04T15:36:17Z")

</div>

Can you report a bug with a little test program?

Thanks!On Tue, Jul 2, 2013 at 1:34 PM, Mason Wheeler wrote:

> Argh. Just noticed the Bottom image was the wrong size. (Trying to  
> simulate something a lot more complicated going on inside the program.)  
> Here’s a better version.
> 
> * * *
> 
> _From:_ Mason Wheeler   
> _To:_ sdl   
> _Sent:_ Tuesday, July 2, 2013 1:27 PM  
> _Subject:_ [SDL] More blitting trouble
> 
> This just keeps getting weirder.
> 
> I’ve got two images (attached), and I’m trying to composite them. The  
> bottom one is an 8-bit PNG, and the top is a 32-bit PNG with an alpha  
> channel that includes a fully-transparent region.
> 
> I load both into surfaces with IMG\_Load. So far, so good. Then I create a  
> new SDL\_Surface to hold the output. I blit Bottom onto it, and then Top,  
> and save to PNG. I expect to see the top image overlaid on the bottom one.
> 
> Instead, what I see depends on the output surface, but either way it’s  
> wrong. If I make the output surface 8-bit, the result is full of garbage,  
> and if I make it 32-bit, the result is all black.
> 
> Any idea what’s going on here? Running SDL2, HG revision 7309 (pretty  
> darn recent) on Windows 7.
> 
> Mason
> 
> * * *
> 
> SDL mailing list  
> SDL at [lists.libsdl.org](http://lists.libsdl.org)  
> [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)
> 
> * * *
> 
> SDL mailing list  
> SDL at [lists.libsdl.org](http://lists.libsdl.org)  
> [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)
