I've narrowed down my problem, but I've yet to find a
solution, so here goes again:
Private Sub Form_Main_KeyDown([usual arguments]) Handles
MyBase.KeyDown
Dim PaintEventArgument As New PaintEventArgs
(CreateGraphics, Nothing)
If e.KeyCode = System.Windows.Forms.Keys.Left Then
For XOffSet = 1 To 40 Step 1 ' Simulate scrolling.
InvokePaint(Me, PaintEventArgument)
Next
XOffSet = 0 ' Scrolling finished.
If CurrentCoords.East > 0 Then ' Reflect new player
position.
CurrentCoords.East = CurrentCoords.East - 1
Else
CurrentCoords.East = Cell.GetUpperBound(0)
End If
ElseIf [Code for other keycodes]
Else
Return ' Exit if key was not recognized.
End If
AssembleMap() ' Uses new CurrentCoords to assemble a new
map.
InvokePaint(Me, PaintEventArgument) ' Displays new map
w/ 0 Offset
End Sub
Private Sub Form_Main_Paint([usual arguments]) Handles
MyBase.Paint
e.Graphics.DrawImageUnscaled(MapInMemoryBitmap, _
XOffSet - 40, _
YOffSet - 40)
End Sub
The problem is slow execution (1.6 seconds, measured
internally) of the 40 DrawImages I call with successively
larger offsets to simulate scrolling upon keydown. The issue
does not appear to be the invocation of the paint event in
doing so, as outsourcing the code to another procedure
(ScrollMap w/ CreateGraphics.DrawImage) showed no
performance increase relative to using the more convenient
InvokePaint.
I've tried using different DrawImage schemes, such as
defining src and dest rectangles, with no appreciable
performance increase.
Repeated transformtranslations might be just what I'm
looking for, but I can't seem to get them to work.
If anybody has any answers or knows a place where I might
find some, I'd be immensely grateful.
The Confessor.