Search code examples
c#pixelpicturebox

Get PixelValue when click on a picturebox


I'm working on a .NET C# project and would like to get the pixel value when I click a picturebox, how can I achieve that?

The basic idea is that when I click anywhere in the picturebox, I get the pixelvalue of that image point..

Thanks!


Solution

  • Use this:

    private void pictureBox2_MouseUp(object sender, MouseEventArgs e)
    {
        Bitmap b = new Bitmap(pictureBox1.Image);
        Color color = b.GetPixel(e.X, e.Y);
    }