Page 1 of 1
(fixed) 1bit transparency in PNGs doesn't work
Posted: Sat May 07, 2011 2:49 pm
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?
Re: Bug: 1bit transparency in PNGs doesn't work
Posted: Sat May 07, 2011 8:00 pm
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.

Re: Bug: 1bit transparency in PNGs doesn't work
Posted: Sat May 07, 2011 8:19 pm
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".
Re: Bug: 1bit transparency in PNGs doesn't work
Posted: Sat May 07, 2011 8:33 pm
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.
Are you doing anything fancy to load it, or just
dsb_get_bitmap?
Re: Bug: 1bit transparency in PNGs doesn't work
Posted: Sat May 07, 2011 8:46 pm
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?
Re: Bug: 1bit transparency in PNGs doesn't work
Posted: Sat May 07, 2011 8:51 pm
by zoom
Gambit, do you work with 256 colours (only)?
why not use regular 32-bit PNGs?
Re: Bug: 1bit transparency in PNGs doesn't work
Posted: Sat May 07, 2011 8:57 pm
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...
Re: Bug: 1bit transparency in PNGs doesn't work
Posted: Sat May 07, 2011 8:58 pm
by Sophia
Yes, send me the image please.

Re: (fixed) 1bit transparency in PNGs doesn't work
Posted: Sun May 15, 2011 9:11 pm
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.