473,320 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 2841
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Steve Long | last post by:
Hello, (total GDI newbie) I'm having trouble drawing just a simple line to display in a picturebox. I just want a straight, dotdash line. I have two methods, one works and one doesn't (it cause...
7
by: news | last post by:
This may be a stupid question, but if I don't ask I'll never know ;) Ok, here it goes.... I am writing an application that renders an image in one picturebox and a graph in another. The image...
4
by: thomasp | last post by:
I found the following code on MSDN to draw a line in VB2005. Public Sub DrawLinePoint(ByVal e As PaintEventArgs) ' Create pen. Dim blackPen As New Pen(Color.Black, 3) ' Create points that...
10
by: Galen Somerville | last post by:
Going from VB6 (RAD) to VB2005 (SAD) The documentation always shows graphics drawing in a paint event like Private Sub Pictcolor_Paint(ByVal sender As Object, ByVal e _ As...
2
by: Martijn Mulder | last post by:
I want to know if the mouse is over (hitting) a line. Therefore I created a Region object that holds the line and use the IsVisible() method to test if the mouse hits the line. It doesn't work! In...
13
by: Martijn Mulder | last post by:
I try to define a line with the length of 1 unit (1 pixel) that is, in fact, just a point on the screen. But when I draw it with a wide pen with the appropriate StartCap and EndCap (Round), it will...
4
by: Galen Somerville | last post by:
I have a real timing problem. This involves getting data from a USB device via an ActiveX dll and drawing trace lines on the screen via a UserControl. The USB device sends six sets of pixel info...
4
by: Galen Somerville | last post by:
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...
5
by: Macias | last post by:
Hi, Please help me, how I can make a line drawing on PictureBox similar to MS paint. I thinking about this: click and hold button, move mouse and relase button. I'm trying useing this...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.