469,658 Members | 1,855 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,658 developers. It's quick & easy.

Quick & Smooth Scrolling in a Graphics item?

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.
Mar 8 '06 #1
0 870

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by James CC | last post: by
8 posts views Thread by Brian Henry | last post: by
reply views Thread by salad | last post: by
1 post views Thread by Bishman | last post: by
reply views Thread by =?Utf-8?B?UGFua2FqR2F1cg==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.