VB2005 Line drawing graphics slow

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Galen Somerville

    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






  • WenYuan Wang

    #2
    RE: VB2005 Line drawing graphics slow

    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


    [DirectDraw and DrawLine]

    Hope this helps,
    Sincerely,
    Wen Yuan

    Comment

    • Galen Somerville

      #3
      Re: VB2005 Line drawing graphics slow

      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-wywang@online.m icrosoft.comwro te in message
      news:1ioQqYkYHH A.1028@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
      >

      [DirectDraw and DrawLine]
      >
      Hope this helps,
      Sincerely,
      Wen Yuan
      >

      Comment

      • WenYuan Wang

        #4
        Re: VB2005 Line drawing graphics slow

        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.

        Comment

        • Galen Somerville

          #5
          Re: VB2005 Line drawing graphics slow

          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-wywang@online.m icrosoft.comwro te in message
          news:o6v5twWZHH A.4088@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.
          >

          Comment

          • WenYuan Wang

            #6
            Re: VB2005 Line drawing graphics slow

            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.

            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

            Comment

            • WenYuan Wang

              #7
              Re: VB2005 Line drawing graphics slow

              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

              Comment

              • Galen Somerville

                #8
                Re: VB2005 Line drawing graphics slow

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

                Galen

                ""WenYuan Wang"" <v-wywang@online.m icrosoft.comwro te in message
                news:I3vleRjaHH A.1176@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
                >

                Comment

                Working...