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!

You need to send the whole code.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.