0

Hi :)
i placed a picturebox and paint on it inside the program with FillRectangle/DrawEllipse/FillEllipse etc.

now all i want is to check if the pixel color under the cursor is == Color.Black

but i encounter problems...

i made this:

Bitmap myBitmap = new Bitmap(this.pictureBox1.Image);

            Color pixelColor = myBitmap.GetPixel(Cursor.Position.X, Cursor.Position.Y);

            if (pixelColor == Color.Black)
            {
                //do something...
            }

but it gives error on the "this.pictureBox1.Image" it says that its not exist
and when i think about it when i paint on picture box its not goes to be the .Image of it... so what is it? its not BackgroundImage also... what should i enter inside the new Bitmap(???)

Thank u!

3
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by ddanbe
1

IMO a PictureBox is specially designde to show pictures.. The Image property will be empty or NULL or what ever if you just draw a rectangle or whatever in it.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.