Link to home
Start Free TrialLog in
Avatar of robholden
robholden

asked on

Slow Plot

I've created a control which basically just draws a trace according to data supplied to it.  It does this using the line(x1,y1)-(x2,y2) function.
Basic problem - it's slow.  I may have up to 32 of these updating continuously in my project, and with the possibility of 1000 data points - this can mean drawing tens of thousands of lines in each iteration - which I want to happen once every two seconds or so.

So, what can anybody suggest?  Is there a better way of drawing these lines which goes faster?  I was hoping I may be able to get each instance of my control to work in parallel using multithreading, but I can't figure it out.

Cheers-
Rob
Avatar of kswinney
kswinney

You can use the API calls "MoveTo" and "LineTo" which will draw significantly faster than VB's line method... but you might also try "Polygon" which will draw several line segments at once.

HTH.
Avatar of robholden

ASKER

I found LineTo and MoveToEx in the WIN32API.  However I can't seem to get them to work.  The API seems to have loads of graphics type calls, its quite overwhelming.  Could you post a bit of sample code to give me a starting point please?

Cheers
Ok, anybody else got any ideas?
Seems you might be able to use a memory DC and just BitBlt or StretchBlt it to where ever. Have some old code somewhere (not for a plot though) if you would like... May B write a leetle Dee el el function, pass an array and a hwnd, and have it update the window?
ASKER CERTIFIED SOLUTION
Avatar of javierma
javierma
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I like this solution - it is seriously fast.

Cheers-
Rob