|
-
Mar 28th, 2004, 03:30 PM
#1
Thread Starter
Fanatic Member
Transparent BitBlt?
I found a tutorial on planet source code, and I understand a bit more about the API, however I am still stuck, as the tutorial didn't cover transparencies. Is there a way to use BitBlt on images with transparent backgrounds, or even have the images show up as transparent when an Alpha channel is used?
-
Mar 28th, 2004, 04:21 PM
#2
The picture isn't missing
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Mar 28th, 2004, 04:24 PM
#3
The picture isn't missing
If you want an easier way, then I found that using vbSrcAnd as the flag will copy everything BUT white. Use white as the transparent colour and :
BitBlt Me.hDC, 0, 0, 100, 100, Picture1.hDC, 0, 0, vbSrcAnd
of course it does not work well if white is one of your colours for your picture.
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Mar 28th, 2004, 04:42 PM
#4
Thread Starter
Fanatic Member
I'm sorry I didn't mention this before, but the tutorial used double buffering to draw the background and the objects. No picturebox is used. Does this matter?
This is the code that paints the background and objects
VB Code:
Private Sub cmdTest_Click()
Dim T1 As Long, T2 As Long
myBackBuffer = CreateCompatibleDC(GetDC(0))
myBufferBMP = CreateCompatibleBitmap(GetDC(0), 320, 256)
SelectObject myBackBuffer, myBufferBMP
BitBlt myBackBuffer, 0, 0, 320, 256, 0, 0, 0, vbWhiteness
mySprite = LoadGraphicDC(App.Path & "\sprite1.bmp")
cmdTest.Enabled = False
T2 = GetTickCount
Do
DoEvents
T1 = GetTickCount
If (T1 - T2) >= 15 Then
BitBlt myBackBuffer, SpriteX - 1, SpriteY - 1, 32, 32, 0, 0, 0, vbBlackness
BitBlt myBackBuffer, SpriteX, SpriteY, 32, 32, mySprite, 0, 0, vbSrcPaint
BitBlt Me.hdc, 0, 0, 320, 256, myBackBuffer, 0, 0, vbSrcCopy
SpriteX = SpriteX + 1
SpriteY = SpriteY + 1
T2 = GetTickCount
End If
Loop Until SpriteX = 320
End Sub
Where would I use vbSrcAnd in this case?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|