|
-
Nov 12th, 2003, 03:00 PM
#1
Thread Starter
Junior Member
Help... New to BitBlting.
I've searched the forums for over an hour and couldn't find an answer to my problem. Everytime I try to use .hDC on anything it says there isn't one. How do I go about fixing this? Here's my code:
Code:
Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (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 System.Int32) As Long
Public Const SRCCOPY = &HCC0020
Public Const SRCPAINT = &HEE0086
Public Const SRCAND = &H8800C6
Public RetVal As Long
Private Sub form2_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
RetVal = BitBlt(Form1.hDC, 0, 0, 320, 200, Picture1.hDC, 0, 0, SRCCOPY))
End Sub
-
Nov 12th, 2003, 03:34 PM
#2
I wonder how many charact
Just use the DrawImage function of the Graphics class. It has 30 overloaded new constructors, and I believe the one you're looking for is toward the end. The code below you could put in a button event, and Me references the current form (obviously). It grabs the picturebox's image and draws it on the form.
VB Code:
Me.CreateGraphics.DrawImage(PictureBox1.Image, Me.DisplayRectangle, 0, 0, _
PictureBox1.Image.Width, PictureBox1.Image.Height, GraphicsUnit.Pixel)
-
Nov 13th, 2003, 03:21 PM
#3
Thread Starter
Junior Member
Thanks but in bitblting you can get rid of that annoying black background behind a sprite right? I found something that looks like it might do that:
Code:
e.Graphics.Clear(System.Drawing.Color.Black)
But whenever I try to make it run this sub:
Code:
Private Sub Draw_Player(ByVal e As PaintEventArgs)
e.Graphics.Clear(System.Drawing.Color.Black)
End Sub
It says: "Argument not specified for parameter 'e' of 'Private Sub Draw_Player(YadaYadaYada)'"
Any ideas?
-
Nov 13th, 2003, 09:53 PM
#4
Fanatic Member
Try changing the Longs in your declaration to int32
If wishes were fishes we'd all cast nets.
-
Nov 14th, 2003, 12:08 AM
#5
Thread Starter
Junior Member
It didn't work. Still got the same problem. It says hDC is not a member of System.Forms
-
Nov 15th, 2003, 08:02 AM
#6
I wonder how many charact
Originally posted by Izzy545
Thanks but in bitblting you can get rid of that annoying black background behind a sprite right? I found something that looks like it might do that:
Code:
e.Graphics.Clear(System.Drawing.Color.Black)
But whenever I try to make it run this sub:
Code:
Private Sub Draw_Player(ByVal e As PaintEventArgs)
e.Graphics.Clear(System.Drawing.Color.Black)
End Sub
It says: "Argument not specified for parameter 'e' of 'Private Sub Draw_Player(YadaYadaYada)'"
Any ideas?
When you say you TRY to make it run Draw_Player, if you're just calling your sub from somewhere in your code, you need to pass the sub a PaintEventArgs class. So just use
VB Code:
Draw_Player(New PaintEventArgs(Me.CreateGraphics, Me.DisplayRectangle)).
That will your Draw_Player sub properly. Now, I'm passing in the form, you can pass whatever it is your drawing on.
Personally, if you're trying to make some sort of game, you might be better off getting a book on game programming in .Net, and even better off learning DirectX.
Last edited by nemaroller; Nov 15th, 2003 at 08:11 AM.
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
|