I'm trying to a draw a track of my position (every second) as current position moves in my navigation program. Latitude/longitude is stored in a structure array every 5 secs - "Dim Type(lat, lon)trackArr (100)".
As the array fills up, the performance starts to drop off rapidly such that when only 20 array elements (approx.) have been filled with lat/lon the execution of the array (see below) takes up so much time that it misses current position updates and takes ages to repond to key/screen touches.
Can anyone suggest a way around this? Is there a more efficient way of storing and displaying the track?
Sub drawTrack
For i=0 To ArrayLen(trackArr())-1
If trackArr(i).lat = "" Then
'Return - this exits sub
Exit ' jump out of for loop as the tr ck array has no values to plot
End If
'Draw track line
If xStart1=0 AND yStart1=0 Then
xEnd1 = X_pix
yEnd1 = Y_pix
xStart1 = X_pix+10 'dummy value for initialisation
yStart1 = Y_pix+10 'dummy value for initialisation
Else
xStart1 = xEnd1 'xEnd from previous iteration
yStart1 = yEnd1 'yEnd from previous iteration
xEnd1 = X_pix
yEnd1 = Y_pix
frmGPS.FLine(xStart1, yStart1 ,xEnd1, yEnd1, cRed)
frmGPS.FLine(xStart1+1, yStart1 ,xEnd1+1, yEnd1, cRed)
End If
Next
xStart1=0 'reset to prevent extraneous lines appearing when good signal and moving map with mouse at start/end of route
yStart1=0
xEnd1=0
yEnd1=0
End Sub
Do you have a code example (sbp file) so we could test it and look where the problem does come from ?
How often and from where do you call the drawTrack routine ?
What is the 2nd line for ?
Is it to have thicker line ? If yes you could use the ImageLibEx, there you can define the line thickness.
In your case, if the line is almost horizontal, there will be no effect.
You're right guys, I was trying to do too much drawing on the forelayer. Just drawing parts of the track that will be visible, performance is much better as I have 1 second between position updates.
Can u confirm if version 1.5 of the ImageLibEx is the latest and do you know if it is any quicker than the FLine method I have been using?
I have never made any speed tests between drawing directly onto the form's forelayer or onto the form with a Drawer object or onto a bitmap with a Drawer object and copying the bitmap onto the form background.
An advatage with the Bitmap is that you can use a bitmap bigger than the screen size and copy the desired part of it onto the form,'s background. But I don't know what would be the influence on speed.
Can u confirm if version 1.5 of the ImageLibEx is the latest and do you know if it is any quicker than the FLine method I have been using?
Any drawing you do ImageLib or ImageLibEx should be faster than a Forms' own drawing methods. This is because the Forms methods repaint the changed area of the Form every time they are used whereas if you use a Drawer to draw on a Form or Bitmap the Form is only redrawn when you use a Refresh method for a Form when you have finished drawing on the Form or have assigned a Bitmap to a Form or Image control.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
The attachment shows an error msg I am getting with the DrawerEx library - "Object Reference Not Set to an Instance of an Object", yet the object exists (SolidBrushEx); see RHS of jpg. Can anyone see what is happening here?
Line 1902 loks OK. It looks like you are trying to draw on a Form's forelayer. Have you enabled that on the Form by "FormName.ForeLayer = True"? As the problem doesn't look like line 1902 itself the problem is elsewhere and you will have to post some source that exhibits it.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
The forelayer is enabled in App_Start. I have noticed that ImageLibEx version 1.5 responds with 1.4 when executing ImageLibEx.DLLversion. Does that shed any light?
No, it's a typo. It is correctly reported as version 1.5 when optimised compiled which you should try as the optimising compiler is pickier than the IDE and may throw up the real source of the error, otherwise you will have to post some source that demonstrates the problem.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.