GDI - DrawLine problem....

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

    #1

    GDI - DrawLine problem....

    Hi,

    Why does the code below only draw the last line of the loop? I was expecting
    this to draw 10 parallel lines. More to the piont....how do I get it to draw
    10 parallel lines?

    Public Function GetImage() As Bitmap
    Dim oBitmap As Bitmap = New Bitmap(200, 200)
    Dim oGraphic As Graphics = Graphics.FromIm age(oBitmap)
    Dim oPen As New Pen(Color.Black , 4)
    Dim i As Integer
    For i = 0 To 10
    oGraphic.DrawLi ne(oPen, i, 0, i, 150)
    Next
    Return oBitmap
    End Function

    Thanks in advance,

    Stu


  • Saber

    #2
    Re: GDI - DrawLine problem....

    It doesn't draws only last line of the loop, since in your loop there is no
    distance between lines it seems like a thick line.
    use something like this loop to draw 10 parallel lines:
    For i = 1 To 10
    oGraphic.DrawLi ne(oPen, i * 15, 0, i * 15, 150)
    Next

    HTH
    --
    Saber S.

    "Stu" <s.lock@cergis. com> wrote in message
    news:eQCK%23yfm FHA.2916@TK2MSF TNGP14.phx.gbl. ..[color=blue]
    > Hi,
    >
    > Why does the code below only draw the last line of the loop? I was
    > expecting this to draw 10 parallel lines. More to the piont....how do I
    > get it to draw 10 parallel lines?
    >
    > Public Function GetImage() As Bitmap
    > Dim oBitmap As Bitmap = New Bitmap(200, 200)
    > Dim oGraphic As Graphics = Graphics.FromIm age(oBitmap)
    > Dim oPen As New Pen(Color.Black , 4)
    > Dim i As Integer
    > For i = 0 To 10
    > oGraphic.DrawLi ne(oPen, i, 0, i, 150)
    > Next
    > Return oBitmap
    > End Function
    >
    > Thanks in advance,
    >
    > Stu
    >[/color]


    Comment

    • Stu

      #3
      Re: GDI - DrawLine problem....

      Thanks - I am duly embarrasssed and shall not try new stuff drunk again!

      "Saber" <saber[.AT.]oxin.ir> wrote in message
      news:uqhchUgmFH A.3656@TK2MSFTN GP09.phx.gbl...[color=blue]
      > It doesn't draws only last line of the loop, since in your loop there is
      > no
      > distance between lines it seems like a thick line.
      > use something like this loop to draw 10 parallel lines:
      > For i = 1 To 10
      > oGraphic.DrawLi ne(oPen, i * 15, 0, i * 15, 150)
      > Next
      >
      > HTH
      > --
      > Saber S.
      >
      > "Stu" <s.lock@cergis. com> wrote in message
      > news:eQCK%23yfm FHA.2916@TK2MSF TNGP14.phx.gbl. ..[color=green]
      >> Hi,
      >>
      >> Why does the code below only draw the last line of the loop? I was
      >> expecting this to draw 10 parallel lines. More to the piont....how do I
      >> get it to draw 10 parallel lines?
      >>
      >> Public Function GetImage() As Bitmap
      >> Dim oBitmap As Bitmap = New Bitmap(200, 200)
      >> Dim oGraphic As Graphics = Graphics.FromIm age(oBitmap)
      >> Dim oPen As New Pen(Color.Black , 4)
      >> Dim i As Integer
      >> For i = 0 To 10
      >> oGraphic.DrawLi ne(oPen, i, 0, i, 150)
      >> Next
      >> Return oBitmap
      >> End Function
      >>
      >> Thanks in advance,
      >>
      >> Stu
      >>[/color]
      >
      >[/color]


      Comment

      Working...