473,794 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 QueryPerformanc eCounter 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(Ne w IntPtr(m_Shared Mem.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.CrtFact or(Nloc)
CurVal = CShort(Not CurVal) + gScreen.CenterL ine(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(ArgX 3, ArgY1, ArgX4, ArgY2, glngColors(Inne r +
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 2872
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.DrawLi ne.

Galen

""WenYuan Wang"" <v-******@online.m icrosoft.comwro te in message
news:1i******** ******@TK2MSFTN GHUB02.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.m icrosoft.comwro te in message
news:o6******** ******@TK2MSFTN GHUB02.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/bd9943a160c52d3 3/2891fad874a82d7 c?lnk=st&q=shar e+memory+vb.net &rnu
m=1&hl=zh-CN#2891fad874a8 2d7c

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.m icrosoft.comwro te in message
news:I3******** ******@TK2MSFTN GHUB02.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
2412
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 an exception to be thrown): This one works but it's not the results I want. private void CreateImage1() {
7
3224
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 is drawn by loading a jpg into a bitmap and then setting picturebox.image = mybitmap. Ive created my own class, inheriting from the picturebox and overriding the OnPaint event so I can do e.Graphics.DrawImage (this.image....). This renders...
4
5161
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 define line. Dim point1 As New Point(100, 100) Dim point2 As New Point(500, 100)
10
1946
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 System.Windows.Forms.PaintEventArgs) Handles PictColor.Paint End Sub But my VB6 program draws to the picturebox PictColor from many different
2
10410
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 the little program below I create two Regions: one is square, the other is a line. Hit testing works on the square-Region, not on the line-Region. How can I do a hit-test over a line? //namespace HitTest namespace HitTest
13
2394
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 appear as a dot. I can think of a way to define a 1-pixel long line but it is ugly and clumsy. I subtract .5 from the given pixel's X and Y coordinate for the first System.Drawing.PointF structure, and add .5 to the other PointF stucture. It...
4
1308
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 so twelve lines have to be drawn on the screen. The first line drawn blacks out a previously drawn line. The second line drawn is from the current data. After this is repeated six times, the program queries the USB device for the next six sets of...
4
1662
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 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...
5
12878
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 g.DrawLine(..), but I have a lot of line. In C++ is a parameter XORPUT, but in C# I can't find it.
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10213
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6779
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.