VB2005 Line drawing graphics slow

  • Thread starter Galen Somerville
  • Start date
G

Galen Somerville

I have been converting a VB6 project to VB2005 for lo these many months.
Most of my problems have been solved thanks to people like WanYuan Wang and
Mattias Sjogren. But now the Graphics aspect is the problem.

This program gets Heart sounds and ECG trace data from a USB device via an
ActiveX thread and an internal DataReciever thread in the main program. The
display is like an oscilloscope in that it sweeps across the screen in real
time.

Six sets of samples are recieved for each update. With a 1,024 X 768 screen
I collect 170 sets of samples or 1,020 pixels worth. The VB6 program will
run at 300 Hearts Beats per minute or a set of samples every 3.412
milliseconds.

The VB2005 program fails at 20 Heart Beats per minute or a set of samples
every 51.12 milliseconds.

Timing test with QueryPerformanceCounter shows the display portion takes
about 55 milliseconds. No wonder it fails !!

The following code snippets tell the story. I hope some graphics experts can
look at my dll and give advice.

Galen


When the 24 bytes are in shared memory are received from USB thread they are
read in as 12 short integers.

Marshal.Copy(New IntPtr(m_SharedMem.ToInt32()), SoundsAry, 0, QuantBy2)

After SoundsAry is received from Data Receiver thread the 12 integers have
to be separated into Heart sounds and ECG and scaled for display into a
PlotAry.

FIXCHNS:
Nloc = 0
Pos = ArgX
For Index = 0 To gParam.NumSmps - 1
CurVal = SoundsAry(Index)
CurVal = CurVal / gScreen.CrtFactor(Nloc)
CurVal = CShort(Not CurVal) + gScreen.CenterLine(Nloc)
If CurVal < 0 Then
CurVal = 5
ElseIf CurVal > gLineY - 5 Then
CurVal = gLineY - 5
ElseIf CurVal < 5 Then
CurVal = 5
End If
PlotAry(Nloc, Pos) = CurVal
Nloc = Nloc + 1
If Nloc = gParam.NumChns Then
Nloc = 0
If gbytSwpdir = 0 Then '0 is left to right. 1 is right
to left.
Pos = Pos + 1
Else
Pos = Pos - 1
End If
End If
Next Index

Then PlotAry, for these six samples, is then processed for display thusly.
Just the code for one set of samples.

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


The Obj.DoLine refers to the PictDraw picturebox on frmSweep. This is a user
control ctlPictDraw.dll which is on my web site at
http://home.surewest.net/galen/download/download.html
 
G

Galen Somerville

I just downloaded the latest activex SDK and will give it a try.

Incidentally the link you referred to seems to be in error. The 1st party
asked for help with DrawLine in DirectDraw and the answer given appears to
be the normal Graphics.DrawLine.

Galen
 
G

Galen Somerville

My current user control uses the g.drawline technique and it's too slow.

I have thought of using ActiveX but it would need to be in a separate thread
with shared memory, I would think.

I already have a thread for ActiveX to interface with USB device and a
separate thread within VB program for matching data reciever.

Is it possible to use the same shared memory for all three threads?

Galen
 
W

WenYuan Wang

Hi Galen,
Thanks for your reply.

It is depend on how you develop the ActiveX, using vb.net or c++? For
vb.net, you can reference the following thread.
http://groups.google.com/group/microsoft.public.dotnet.languages.vb/browse_f
rm/thread/bd9943a160c52d33/2891fad874a82d7c?lnk=st&q=share+memory+vb.net&rnu
m=1&hl=zh-CN#2891fad874a82d7c

Additionally, if you have a concern on the performance of g.drawline(),we
suggest you may consider using DirectX. I think this will bring more
performance.
If you are interesting in it, I will search some documents about this
method for you.

Have a great day.
Sincerely
Wen Yuan
 
W

WenYuan Wang

Hi Galen,

Have you resolved the issue?
If there is anything we can help with, please feel free to update here. I'm
glad to assist you.

Have a great day,
Sincerely,
Wen Yuan
 
G

Galen Somerville

Still have problems. Trying Directx but still problems. Sent email to WenJun
Zhang to see if he could help.

Galen
 

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

Top