You are not being clear. Are you talking about the coordinates of the image, or the coordinates of the picturebox? They will only be the same when you use the picturebox Image and set the picturebox's SizeMode to None.
Assume your picturebox is called PictureBox1 and you want the colour of the pixel at coordinates x, y. If the coordinates are relative to the image, all you need is:
If the coordinates are relative to the picturebox and you want it to work for any SizeMode including Stretch, Zoom etc., you can get a snapshot of the picturebox like this:Code:Dim pixelColor As Color = PictureBox1.Image.GetPixel(x, y)
Code:Dim w As Integer = PictureBox1.ClientSize.Width Dim h As Integer = PictureBox1.ClientSize.Height Dim bmp As New Bitmap(w, h) PictureBox1.DrawToBitmap(bmp, PictureBox1.ClientRectangle) 'bmp is now a snapshot of the picturebox. So get the pixel colour... Dim pixelColor As Color = bmp.GetPixel(x, y)
BB




Reply With Quote
