Speed issues on vector map drawing

junglejet

Active Member
Licensed User
Longtime User
I have stripped down the application to what are the two problems I have:

(i) The drawing speed is still very slow (ticks shown in form1 caption). On the PC I have 250 ticks, on the device 7000. I have tried to do a lot, amongst it a pure integer coordinates conversion but this doesn't speed up at all. Actually it becomes even slower. I run out of ideas now, but I know there are means that can draw polylines much much faster, like in BeelineGPS, which is a GPS tracker BeeLineGPS™.

(ii) The imagelib exception with the line pen1.color=color1 still persists, albeit now only when the screen is converted to Fullscreen or back. Sometimes also an NullReferencePointer exception is thrown. The line can be commented and changed to pen1.new1(color1) in the source (then also the initial new1 in App_start needs to be commented).

The zip attached has all the required files in it. The exception should be reproducable on the device.

Thanks

Download: http://jetvision.de/download/test.zip (due to size unable to attach here)
 
Last edited:

junglejet

Active Member
Licensed User
Longtime User
Uploaded again with bas files (all may not be necessary, but they were in the source folder)

:sign0013:
 

agraham

Expert
Licensed User
Longtime User
Your null reference is because you have not Newed your obj Object.

B4X:
Sub ReturnTitle
[COLOR="Red"]  obj.New1(False)[/COLOR]
  obj.FromControl("form1")

As I suggested previously the Graphics saved in Drawer1 seems to be invalidated when you change the Form size. It works fine for me if you reset it though this may not be the best place to do it.
B4X:
Sub drawmap
   WaitCursor(True)
[COLOR="red"]   drawer1.New1("Form1", False)[/COLOR]
   start1=hw.GetTickCount
The drawing speed doesn't seem too bad to me. My PC shows 156-172 ticks and my iPAQ 214 shows 3493-4435 ticks. I can't see a way of dramatically speeding up the drawing but I'll think about it.
 

agraham

Expert
Licensed User
Longtime User
I've looked more closely at your drawing and it can be improved.

You need to check the contents of your wpte, wptn and wptid arrays as they are non-optimal. wptn and wpte seem to contain duplicated data so you are drawing some/all of the squares twice and not every entry in wptid is valid so you are calling drawstring unnecessarily.

I don't understand the structure of your outline data but you could speed up their drawing by pre-processing the data and drawing them differently. Instead of drawing the long line as a whole set of individual small segments you should draw it as a single long line. Similarly the cross lines should be drawn as a single line rather than as two lines, one on each side of the main line.
 

junglejet

Active Member
Licensed User
Longtime User
Your null reference is because you have not Newed your obj Object.

Thanks for that, it was inadvertently deleted in the test source, it was present in App_Start in the real source.

As I suggested previously the Graphics saved in Drawer1 seems to be invalidated when you change the Form size. It works fine for me if you reset it though this may not be the best place to do it.
B4X:
Sub drawmap
   WaitCursor(True)
[COLOR="red"]   drawer1.New1("Form1", False)[/COLOR]
   start1=hw.GetTickCount

I will try that, I may be still too hesitating to new objects that were not freed.

You need to check the contents of your wpte, wptn and wptid arrays as they are non-optimal. wptn and wpte seem to contain duplicated data so you are drawing some/all of the squares twice and not every entry in wptid is valid so you are calling drawstring unnecessarily.

I don't understand the structure of your outline data but you could speed up their drawing by pre-processing the data and drawing them differently. Instead of drawing the long line as a whole set of individual small segments you should draw it as a single long line. Similarly the cross lines should be drawn as a single line rather than as two lines, one on each side of the main line.

You are right, the data files are substandard. I shall forfeit waypoints that do not contain IDs, which will help. The outlines are split up because the mother application for which they are auto generated fully surpresses lines that have one end outside the visible screen. It seems the generator therefore splits them up into small pieces. In total I cannot do much about the data, they come with the mother application.

Thank you very much for your efforts.
 

klaus

Expert
Licensed User
Longtime User
Hi junglejet,

I played a bit with your program and changed some parts.

- moved the screen coordinate calculation from the draw routine to the load routine.
- if you don't need the minute and 5 minute ticks in the outline lines you will gain a lot of time if these are always straight lines.
- removed the double wpt coordinates.

On my Qtek the refresh goes from 2900 ticks down to 270 ticks (without the minute ticks, drawing just the line between the first and last point).

Acording to the data variations and your needs the out lines would become somewhat more complicated and with a drawing time increase.

If you always need to load the files before the drawing, the move of the calculation of the screen coordinates to the load routine will not bring a time decrease.

Attached the test program.

Best regards.
 

junglejet

Active Member
Licensed User
Longtime User
Hello Klaus,

thank you for your efforts. Loading the files is only done once on program start in the real source.

As mentioned above, the outlines cannot be changed, they are simply there already, in the public domain.

Ciao
Andy

EDIT: they long term way to go? Graphics with DirectX in Windows Mobile 5.0 Games
 
Last edited:

klaus

Expert
Licensed User
Longtime User
Hi junglejet,

If I understand well, the complete outlines come from x.out files and you create point coordinates to draw them.
My simple outlines with only the 2 end points are also 'picked out' of the same original x.out file in the loadout1 routine.

I had a short look at the DirectX documentation, interesting. Perhaps there will be one time a library for that.

Best regards.
 

agraham

Expert
Licensed User
Longtime User

agraham

Expert
Licensed User
Longtime User
As mentioned above, the outlines cannot be changed, they are simply there already, in the public domain.
If I understand correctly Klaus has done what I suggested in "pre-processing the data and drawing them differently". I think he has done exactly that and processed your public domain data to draw it more efficiently.
 

agraham

Expert
Licensed User
Longtime User
A correction to my previous code fgragment, it should have been this

B4X:
Sub drawmap
   WaitCursor(True)[COLOR="red"]
   drawer1.Dispose
   AddObject("drawer1", "Drawer")
   drawer1.New1("Form1", False)[/COLOR]
   start1=hw.GetTickCount
This is because a Drawer uses a native Graphics object and a bug in the current version of Basic4ppc does not free up renewed instances of library objects and so doesn't free up the native resources which leads to a memory leak.
 
Top