-
hello,
im making a game and the question is about the charactors graphic. how do i make the background of the charactor transparent? i can change the backdrop to make the charactors background, but if i pass a different color it looks bad. any ideas?
-thanks
-t_dawolf
-
Create your sprite with a black background. Use BitBlt to copy the image and for the OpCode, put SRCPAINT so it wont copy the black, therefor, leaving you with a transparent background.
-
Indeed. (First vbSrcPaint then vbSrcAnd)
You can also download some example projects from my homepage. ;)
-
hey,
thanks for the help, could i get some help with that though?
i mean some code? i got the guy as an image and his name is "trum". so any help with code would be greatly appreciated.
-thanks
-t_dawolf
-
Like I said, look on my website. You'll find a very easy and well-commented BitBlt example there...
-
Put the following code in a module.
Code:
Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Put the following code into a CommandButton. Make sure that the ScaleMode for everything is set to Pixels.
Code:
Private Sub Command1_Click()
'Copy the Mask
RetVal = BitBlt(Form1.hDC, 0, 0, 32, 32, picMask.hDC, 0, 0, SRCPAINT)
'Copy the sprite
RetVal = BitBlt(Form1.hDC, 0, 0, 32, 32, picSprite.hDC, 0, 0, SRCAND)
End Sub
This should work.
[Edited by Megatron on 05-18-2000 at 04:39 PM]