Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Strange problem with transparent png's.

This thread is locked; no one can reply to it. rss feed Print
Strange problem with transparent png's.
netcat
Member #6,097
August 2005

Attached are two screenshots from two apps, one using allegro and the loadpng library and the other using the FOX GUI toolkit, and also the tileset itself (from RPG Maker XP) so you can see how it is supposed to look. I suspect it might be the semi transparent shadows from the trees and such that causes it, because other images with just transparent backgrounds work fine (and images similar to the attached are broken).

Anyone know what's wrong? Is my libpng broken? :-/

kazzmir
Member #1,786
December 2001
avatar

Whats the problem? The gigantic black box on the right side in the Allegro application? Other than that the gui and allegro look the same to me.

netcat
Member #6,097
August 2005

You'll see the problem if you look at the third attachment; the loaded image is all screwed up.

gnolam
Member #2,030
March 2002
avatar

... all screwed up how? The third attachment looks fine to me.

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

netcat
Member #6,097
August 2005

The third attachment is how it's supposed to look... "the loaded image" = the image as it shows up in the applications.

kazzmir
Member #1,786
December 2001
avatar

Oh, the fox gui and allegro show the sprite the same so I thought there were no problems.

Are you doing anything special to show the sprite in allegro? or is it basically

BITMAP * all = load_sprite( ... );
blit( all, screen, ... );

?

netcat
Member #6,097
August 2005

Simply doing

tileset = load_png( ..., 0)
...
blit(tileset, buffer, ... )

Also, just tested loading in SDL and it works fine there.

CGamesPlay
Member #2,559
July 2002
avatar

The PNG is being loaded without an alpha channel, apparently.

I don't know anything about loadpng or FOX GUI though, so I can't help more than that.

[append]

Here's the same image drawn with Allegro's magic pink as the background. Try using it, instead.

You will need to used masked_blit instead of blit.

masked_blit

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Paul whoknows
Member #5,081
September 2004
avatar

Convert you PNG files to TGA and load it using Allegro.

____

"The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner.

CGamesPlay
Member #2,559
July 2002
avatar

Converting it to TGA isn't necessary. He could keep it as PNG like I suggested in my post, or he could use Allegro's software blending techniques:

[append]

I vote that we call this problem the Invisible Pink Unicorn Syndrome

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

netcat
Member #6,097
August 2005

CGamesPlay said:

set_alpha_blender

Doh, hadn't noticed that function before. Calling that makes it work perfectly, obviously.

Thanks!

Paul whoknows
Member #5,081
September 2004
avatar

____

"The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner.

Go to: