mookie0001
Technical User
Hi everyone,
I am trying to smoothly scroll a VERY large image across a form. Unfortunately, I am getting very bad flickering problems. One helpful person recommended that I blit only the screen size instead of the entire picture. Unfortunately, I followed a tutorial to get this far and do not quite understand how I would go about doing this. Can someone give me a few pointers on this, or recommend other ways to stop the flickering (code snippets would be helpful). Thanks in advance!
-Chris
Here is my current source code:
Dim gameboard_image As New Bitmap("e:\hugePicture.jpg"
'Create the target graphics and get an hDC from it
Dim formGraphics As Graphics = Me.CreateGraphics()
Dim targethDC As IntPtr = formGraphics.GetHdc()
'Create an offscreen dc and select our bitmap in to it
Dim offscreenhDC As IntPtr = CreateCompatibleDC(targethDC)
Dim oldObject As IntPtr = SelectObject(offscreenhDC, gameboard_image.GetHbitmap())
Private Sub form2_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
BitBlt(targethDC, m_dragOffset.X, m_dragOffset.Y, gameboard_image.Width, gameboard_image.Height, offscreenhDC, 0, 0, SRCCOPY)
End Sub
I am trying to smoothly scroll a VERY large image across a form. Unfortunately, I am getting very bad flickering problems. One helpful person recommended that I blit only the screen size instead of the entire picture. Unfortunately, I followed a tutorial to get this far and do not quite understand how I would go about doing this. Can someone give me a few pointers on this, or recommend other ways to stop the flickering (code snippets would be helpful). Thanks in advance!
-Chris
Here is my current source code:
Dim gameboard_image As New Bitmap("e:\hugePicture.jpg"
'Create the target graphics and get an hDC from it
Dim formGraphics As Graphics = Me.CreateGraphics()
Dim targethDC As IntPtr = formGraphics.GetHdc()
'Create an offscreen dc and select our bitmap in to it
Dim offscreenhDC As IntPtr = CreateCompatibleDC(targethDC)
Dim oldObject As IntPtr = SelectObject(offscreenhDC, gameboard_image.GetHbitmap())
Private Sub form2_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
BitBlt(targethDC, m_dragOffset.X, m_dragOffset.Y, gameboard_image.Width, gameboard_image.Height, offscreenhDC, 0, 0, SRCCOPY)
End Sub