VB2005 line drawing speedup

G

Galen Somerville

My VB2005 app gets real time Heart sounds and an ECG from a USB device. I'm
looking for a way to speed up the drawing of the traces on the screen.

In the following code the routine GetSounds recieves the USB data for six
consequtive horizontal pixels (or 6 sound/ECG samples). The routine FixChns
handles the scaling of the data and puts it into the PlotAry for
presentation.

The variable RptCnt then handles the placement for the 6 sets of samples.
The call to Obj.DoLine draws lines from previous pixel location to current
pixel location.

For Index = gScreen.HorPixels - Gap - 1 To gScreen.HorPixels - 2
Step 1
If RptCnt = 0 And Index < gScreen.HorPixels - 6 Then
Call GetSounds()
If ErrFlg Then
Exit Sub
End If
Call FixChns(ArgX3 + 6)
If ErrFlg Then
Exit Sub
End If
End If
For Inner = 0 To NumChns - 1 Step 1
ArgY2 = PlotAry(Inner, Index + 1)
ArgY1 = PlotAry(Inner, Index)
Obj.DoLine(ArgX3, ArgY1, ArgX4, ArgY2, glngColors(Inner +
4))
Next Inner
ArgX3 = ArgX3 + 1
ArgX4 = ArgX4 + 1
RptCnt = RptCnt + 1
If RptCnt = 6 Then RptCnt = 0
Next Index

Obj.Doline is a call to a ctlPictDraw class which is on my web site

http://home.surewest.net/galen/download/download.html

There are other drawing routines in the dll but they do not require any
speedup.

The actual display is like an oscilloscope display with a moving gap. The
above code is actually the third procedure. The second procedure is
complicated by calling Obj.DoLine to remove the traces from previous screen
sweep before drawing the new lines (on an xor basis). The first procedure
merely calls Obj.DoLine to remove x number of lines to create the start of
the moving gap.

At the end of a sweep the PlotAry is copied to a PrevAry

Whew. I would appreciate a graphics drawing guru to take a look at this
whole mess.

Galen
 
C

Cor Ligthert [MVP]

Galen,

The only thing I know to speed up lines is to use groupboxes where both
lines are on the same position.

Cor
 
G

Galen Somerville

Cor

It would be rare when lines are in the same position from sweep to sweep.

Galen
 
W

WenYuan Wang

Hi Galen.

I'm afraid it is difficult to improve the performance without actual data
and environment.
But in general, we will suggest using DirectDraw or DirectShow to get more
performance.

Hope this will help.
Best regards,
Wen Yuan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top