|
-
Jan 5th, 2002, 10:34 PM
#1
Thread Starter
Addicted Member
CreateCompatibleDC question
I am loading 2 images (sprite and mask) into DC that I have created using the CreateCompatibleDC api, and then I blit them into the screen. My question is: How do I create another dc so I can blit the new transparent image (result of mask + sprite) into it, and not into the form.
The code I am using is the following, but it doesn't work, even though I don't get any errors. But is works OK when I blit them into the screen.
VB Code:
Private Sub Form_Activate()
'Create DC
MaskDC = CreateCompatibleDC(Me.hdc)
SpriteDC = CreateCompatibleDC(Me.hdc)
FinalImageDC = CreateCompatibleDC(Me.hdc)
'Load images
MaskIM = LoadImage(0, "C:\WINDOWS\Desktop\Henrique\Shooter\Images\target_hit_mask.bmp", 0, 0, 0, &H10)
SpriteIM = LoadImage(0, "C:\WINDOWS\Desktop\Henrique\Shooter\Images\target_hit_sprite.bmp", 0, 0, 0, &H10)
'Link DC with image
SelectObject MaskDC, MaskIM
SelectObject SpriteDC, SpriteIM
'Go through each separate part of the images
Do
DoEvents
Me.Cls
'This is what does not work, the FinalImageDC
BitBlt FinalImageDC, 10, 10, 30, 74, MaskDC, x, 0, vbSrcAnd
BitBlt FinalImageDC, 10, 10, 30, 74, SpriteDC, x, 0, vbSrcPaint
x = x + 31
If x >= 740 Then
x = 0
End If
Loop Until GameOver = True
End Sub
Is this the right way of doing this, or is there another API call for this?
Thanks
-
Jan 6th, 2002, 12:26 PM
#2
You need to select a bitmap for FinalImageDC. You can do this using the CreateCompatibleBitmap function to create the bitmap, and use SelectObject to attach it to the DC.
-
Jan 6th, 2002, 03:05 PM
#3
Thread Starter
Addicted Member
Sorry to ask you this, but I just lost everything in my computer, and don't have this project...
Would it be like this?
VB Code:
FinalImageDC = CreateCompatibleDC(Me.hdc)
FinalImage = CreateCompatibleBitmap(FinalhImageDC, 20, 20)
SelectObject FinalImageDC, FinalImage
-
Jan 6th, 2002, 04:13 PM
#4
-
Jan 6th, 2002, 04:57 PM
#5
Thread Starter
Addicted Member
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
|