Black is always transparent?

BlitzPlus Forums/BlitzPlus Programming/Black is always transparent?

DrMartin(Posted 2003) [#1]
Hi everybody

I have a weird problem with a small game I'm writing. I've searched the forums without finding any answers. If this is something really basic, please forgive me.
The problem is that when I blit an image, all its black (0,0,0) pixels become transparent. I haven't used maskimage or anything like that. I don't want the black pixels to be transparent! Of course I could redraw the graphics and use 1,1,1 as black instead of 0,0,0 but that just feels stupid.

Here's a small test-program I wrote:

Graphics 640,480,0,2
pic=LoadImage("test.png")
ClsColor 51,102,153
While Not KeyDown(1)
	SetBuffer BackBuffer()
	Cls
	DrawImage(pic,100,100)
	Flip
Wend


Any ideas?

--
Martin Gunnarsson


ErikT(Posted 2003) [#2]
Have you tried a different format than .png?


Myke-P(Posted 2003) [#3]
pic=LoadImage("test.png")
MaskImage pic,255,0,255


Mask it to any other colour you like (255,0,255 - Magenta is common 'cos it's such a damn ugly colour and unlikely to be used in your image) and only those colours will be transparent with DrawImage.

Alternatively, if you require *no* transparent pixels whatsoever, use DrawBlock.


DrMartin(Posted 2003) [#4]
Yes, same thing with JPEG.


DrMartin(Posted 2003) [#5]
Yeah, that did the trick! Fastest reply ever!
Drawblock is faster than drawimage, isn't it?


Myke-P(Posted 2003) [#6]
If you were drawing (estimate:) 1000 images per frame on a Pentium 266 then you might see a difference between DrawBlock and DrawImage (due to the former not having to check for transparent pixels). For most users the difference will be negligable.

My general rule is; if I need transparent (i.e. invisible) pixels then I use DrawImage, otherwise I use DrawBlock. :)


okee(Posted 2003) [#7]
DRMartin just for the record I know you just knocked up that example quick, but you only need to do SetBuffer BackBuffer() once, so it's better keep it outside the main loop...


DrMartin(Posted 2003) [#8]
Hm, I didn't know that, thanks.