(fixed) 1bit transparency in PNGs doesn't work

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
User avatar
Gambit37
Should eat more pies
Posts: 13766
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

(fixed) 1bit transparency in PNGs doesn't work

Post by Gambit37 »

If I load a PNG with 1bit transparency set, it's not made transparent in-game, it's rendered on a black background.

Can this be fixed please?
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Bug: 1bit transparency in PNGs doesn't work

Post by Sophia »

I'll admit a large part of why this doesn't work probably has to do with the fact that I don't have a clue what you're talking about. :)

The library should be converting all of that stuff to an alpha channel at the same time as it internally converts it to Allegro's internal 32-bit format. If it's not working right it's a bug in code I didn't write. :shock:
User avatar
Gambit37
Should eat more pies
Posts: 13766
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Bug: 1bit transparency in PNGs doesn't work

Post by Gambit37 »

1bit transparency -- you know, when you make a single colour in a 256 colour image the transparent colour? It's like having power pink behind your image, but in the PNG it saves it as "transparent".
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Bug: 1bit transparency in PNGs doesn't work

Post by Sophia »

Ok. This should be getting promoted to a full alpha channel at the same time that the image gets converted to the internal 32 bit format.
If it's not.. hmm. :shock:

Are you doing anything fancy to load it, or just dsb_get_bitmap?
User avatar
Gambit37
Should eat more pies
Posts: 13766
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Bug: 1bit transparency in PNGs doesn't work

Post by Gambit37 »

It's just dsb_get_bitmap(). Regular 32-bit PNGs work fine, by the way. Do you want me to send you the PNG for testing?
User avatar
zoom
Grand Master
Posts: 1819
Joined: Tue Sep 23, 2003 1:27 am
Location: far away but close enough

Re: Bug: 1bit transparency in PNGs doesn't work

Post by zoom »

Gambit, do you work with 256 colours (only)?
why not use regular 32-bit PNGs?
User avatar
Gambit37
Should eat more pies
Posts: 13766
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Bug: 1bit transparency in PNGs doesn't work

Post by Gambit37 »

I work with what ever is appropriate for the image in question. A lot of images simply don't need to be 32-bit (well, technically 24-bit colour + an 8bit alpha channel). You can often downsample to adaptive 256 colour palettes for most images without losing noticeable quality.

8bit PNGs are much, much smaller on disk than 32-bit images too, so will make for a much smaller download. (Of course, you could argue that zipping a 32-bit image makes the same saving as converting to 8bit and that's probably true, but I'd rather have smaller files to begin with, I just find it more efficient all round. )

The custom dungeon I'm developing uses old-school pixellated graphics, so I mostly don't need to use full alpha channels -- which is why 8bit PNGs with 1bit alpha is sufficient. I could of course put power pink in all my images, but I've already generated hundreds without power pink and don't really wanna go back and do it all again...
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Bug: 1bit transparency in PNGs doesn't work

Post by Sophia »

Yes, send me the image please. :D
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: (fixed) 1bit transparency in PNGs doesn't work

Post by Sophia »

Fixed now.

For the sake of efficiency, DSB's drawing routines will try to mask by power pink or alpha channel, never both. The decision which to do is made when the image is loaded. The 1 bit ones were being sent down the power pink pipe by mistake because they didn't have a "proper" 8 bit alpha value.
Post Reply