no transparency?

BlitzPlus Forums/BlitzPlus Programming/no transparency?

dgroncki(Posted 2003) [#1]
I'm having a problem getting an image to draw transparent. I'm saving out of Photoshop (6) and have tried:

1. PNG24 with no background layer and "save for web" as PNG with transparency. Image draws with missing areas white.

2. PNG24 with black as what should be transparent. Most of black area is transparent, but I get several black (dark) artifacts near the non-transparent edges.

Help?

thanks...Dave


GfK(Posted 2003) [#2]
You can't use alpha in 2D, if that's what you're getting at.

PNG24 with black as what should be transparent. Most of black area is transparent, but I get several black (dark) artifacts near the non-transparent edges.
That's likely due to Photoshops own antialiasing. Try trimming the edges with the "contract" tool to get rid of the antialiasing and give your sprite a sharp edge.


dgroncki(Posted 2003) [#3]
So there's no way to create png's such that Blitz2D will interpret their transparency? It seems like the LoadImage/DrawImage commands talked about preserving transparency, but it seems quirky.


keyboard(Posted 2003) [#4]
You don't have to set the transparency in Photoshop, its not necessary. And if you set transparency, it won't matter, you have to define the transparency in Blitz+ or Blitz2D with Maskimage.

Black is transparent by default, and you use Maskimage to set any other colour as the transparent colour

Global MySprite = Loadimage("sprite.png")
Maskimge MySprite 0,255,0

this makes bright green the transparent colour.

The dark artifacts near the edges are the effects of anti-aliasing as Gfk says, they are the dark graduation colours, but not actual "0,0,0" BLACK. If your game world has a black background, you will not notice them, otherwise, as above, you have to turn off anti-aliasing in your drawing tools so you draw with a crisp edge...


ErikT(Posted 2003) [#5]
If you got an anti-aliased image you want to convert to an aliased one, here's one (tedious) way to do it:

Load the image in Photoshop. Create a separate layer you fill with the transparent colour and move it to the bottom of the layer list. Duplicate the main layer 30 times, then merge it down to two layers, one main layer and one background layer(the one you filled with the transparency colour). Repeat this two more times. You should now have a sprite with a dark border on top of the background layer.

Now go into the menu and convert the image to 256 colours. Then save it's palette in the Colour Table menu. Close the image without saving and then reload it. Convert the reloaded image to indexed and load the palette you saved earlier. Presto! Clean, crisp sprite-edges with all other antialiasing preserved. The minus is having to convert your image to 256 colours, but with a dedicated palette it should still look good. And if you have lots of images for animation of the same sprite, you can just load the created palette onto them too without going through the whole layer-duplicating thing all over again.


bazziman(Posted 2003) [#6]
I think it's easer in photo shop to use the 'magic wand' tool AROUND the object, then expand the selection by 1 or 2 pixels and with a moderate tollerance (32), antialiasing OFF, AND contiguous OFF start painting in the dark but not yet black pixels with pure black.

It's even easier if you first use the magic wand to put the image on top of a bright green or whatever layer so you can still see the pixels left to do: paint them using the same colour as the background and either then flatten the image and use the new background colour as a mask or repaint it pure black.