get each pixel from an image c# code example
Example 1: get color of pixel c#
static Color GetPixel(Point position)
{
using (var bitmap = new Bitmap(1, 1))
{
using (var graphics = Graphics.FromImage(bitmap))
{
graphics.CopyFromScreen(position, new Point(0, 0), new Size(1, 1));
}
return bitmap.GetPixel(0, 0);
}
}
Example 2: c# get pixel from bitmap click
private void pictureBox_MouseUp(object sender, MouseEventArgs e)
{
Bitmap b = new Bitmap(pictureBox.Image);
Color color = b.GetPixel(e.X, e.Y);
}