3 Replies - 360 Views - Last Post: 13 November 2019 - 02:31 PM Rate Topic: -----

#1 shemmy   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 21-October 19

Painting a small dot on a image

Posted 13 November 2019 - 01:58 PM

I was trying to load a image from file to a picture box and painting a small red circle.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        PictureBox1.Image = Image.FromFile("F:\Image\I637924.jpg")
        Using p As New System.Drawing.Pen(Color.Red, 4)
            Using g As Graphics = PictureBox1.CreateGraphics()
                g.DrawEllipse(p, 5, 5, 10, 10)
            End Using
        End Using
    End Sub


The image was created but no red dot.
Separating this in 2 steps:
1. load the image
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        PictureBox1.Image = Image.FromFile("F:\Image\I637924.jpg")
    End Sub


2. paint
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Using p As New System.Drawing.Pen(Color.Red, 4)
            Using g As Graphics = PictureBox1.CreateGraphics()
                g.DrawEllipse(p, 5, 5, 10, 10)
            End Using
        End Using
    End Sub



works - can you tell me why it didn't work as combined action?

Is This A Good Question/Topic? 0
  • +

Replies To: Painting a small dot on a image

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15476
  • View blog
  • Posts: 62,006
  • Joined: 12-June 08

Re: Painting a small dot on a image

Posted 13 November 2019 - 02:08 PM

largely possible the paint for that control is happening after you draw your circle and isbeing overwritten.. breaking it apart breaks up the quickness.
Was This Post Helpful? 0
  • +
  • -

#3 shemmy   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 21-October 19

Re: Painting a small dot on a image

Posted 13 November 2019 - 02:28 PM

View Postmodi123_1, on 13 November 2019 - 02:08 PM, said:

largely possible the paint for that control is happening after you draw your circle and isbeing overwritten.. breaking it apart breaks up the quickness.



Is there a way to execute this in one way?
Enter a wait or loop till the paint has finished?
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15476
  • View blog
  • Posts: 62,006
  • Joined: 12-June 08

Re: Painting a small dot on a image

Posted 13 November 2019 - 02:31 PM

You would want to test that out first to see if that's the case. Paint on controls gets weird as it's generally operate outside of direct control.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1