Black is always transparent?
BlitzPlus Forums/BlitzPlus Programming/Black is always transparent?
| ||
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 |
| ||
Have you tried a different format than .png? |
| ||
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. |
| ||
Yes, same thing with JPEG. |
| ||
Yeah, that did the trick! Fastest reply ever! Drawblock is faster than drawimage, isn't it? |
| ||
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. :) |
| ||
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... |
| ||
Hm, I didn't know that, thanks. |