472,126 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,126 software developers and data experts.

VB2005 Line drawing graphics slow

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

Mar 8 '07 #1
7 2724
Hi Galen,

Just some suggestion: You may use Windows API to draw line in VB.net. Such
as :
Declare Function LineTo Lib "gdi32.dll" (ByVal hdc As IntPtr, ByVal x As
Integer, ByVal y As Integer) As Boolean

https://forums.microsoft.com/MSDN/Sh...74682&SiteID=1
[DirectDraw and DrawLine]

Hope this helps,
Sincerely,
Wen Yuan

Mar 9 '07 #2
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

""WenYuan Wang"" <v-******@online.microsoft.comwrote in message
news:1i**************@TK2MSFTNGHUB02.phx.gbl...
Hi Galen,

Just some suggestion: You may use Windows API to draw line in VB.net. Such
as :
Declare Function LineTo Lib "gdi32.dll" (ByVal hdc As IntPtr, ByVal x As
Integer, ByVal y As Integer) As Boolean

https://forums.microsoft.com/MSDN/Sh...74682&SiteID=1
[DirectDraw and DrawLine]

Hope this helps,
Sincerely,
Wen Yuan

Mar 9 '07 #3
Hi Galen,

For the thread in
https://forums.microsoft.com/MSDN/Sh...74682&SiteID=1, I
just want to show you an example about how to use DrawLine in VB.net

By the way, have you tried with Activex SDK?
If there is any issue we can help, please feel free to update here and we
will follow up.

Have a great day,
Sincerely,
Wen Yuan.

Mar 13 '07 #4
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

""WenYuan Wang"" <v-******@online.microsoft.comwrote in message
news:o6**************@TK2MSFTNGHUB02.phx.gbl...
Hi Galen,

For the thread in
https://forums.microsoft.com/MSDN/Sh...74682&SiteID=1, I
just want to show you an example about how to use DrawLine in VB.net

By the way, have you tried with Activex SDK?
If there is any issue we can help, please feel free to update here and we
will follow up.

Have a great day,
Sincerely,
Wen Yuan.

Mar 13 '07 #5
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/micro...es.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

Mar 14 '07 #6
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

Mar 19 '07 #7
Still have problems. Trying Directx but still problems. Sent email to WenJun
Zhang to see if he could help.

Galen

""WenYuan Wang"" <v-******@online.microsoft.comwrote in message
news:I3**************@TK2MSFTNGHUB02.phx.gbl...
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

Mar 19 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Steve Long | last post: by
7 posts views Thread by news | last post: by
4 posts views Thread by thomasp | last post: by
10 posts views Thread by Galen Somerville | last post: by
2 posts views Thread by Martijn Mulder | last post: by
13 posts views Thread by Martijn Mulder | last post: by
4 posts views Thread by Galen Somerville | last post: by
4 posts views Thread by Galen Somerville | last post: by
5 posts views Thread by Macias | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.