I got a picbox in my function which store
the image as bitmap,
i now need a function that can
find out the colour RGB components of any given pixel when i move my mouse on to it
what should i do to get this?
I have success to display the RGB and pixel in selected textbox
but when i move my mouse out side of the picture box
there’s error msg came out:
Parameter must be positive and < Width.
Parameter name: x
i try to use If e.X > 300 Then e.X = 300
but it said “e.X” is for read only
My Code current looks like this:
If pixBox1.Image Is Nothing Then Exit Sub
txtColourPixel.Text = String.Format("x,y = {0},{1}; Color={2}", e.X, e.Y, DirectCast(pixBox1.Image, Bitmap).GetPixel(e.X, e.Y).ToString)
You COULD do it like this:
UPDATE: SOMETIMES the Move handler gives coordinates OUTSIDE of the actual image. Oned could handle this, or just ignore:
GetPixelis the method you want.