C#中 怎么获得某一个控件中图片的某一点像素的颜色值啊?

C#中 怎么获得某一个控件中图片的某一点像素的颜色值啊?
比如我要实现
panel1.Image的12,12坐标上的像素的Color (ARGB)的信息

要使用GetPixel函数来取得像素的颜色值,代码如下:

        private void button1_Click(object sender, EventArgs e)
        {
            Color color = new Bitmap(pictureBox1.Image).GetPixel(10, 10);
            MessageBox.Show(color.ToString());
        }

效果见下图:

温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-11-16
c++中获得某一个控件中图片的某一点像素的颜色值(坐标可以自行设置):
代码注释可以查询c++的编程手册。
[C#]
public void GetPixel_Example(PaintEventArgs e)

{

// Create a Bitmap object from an image file.

Bimap myBitmap = new Bitmap("Grapes.jpg");

// Get the color of a pixel within myBitmap.

Color pixelColor = myBitmap.GetPixel(50, 50);

}
————————————————————————————————————
myColor.R//
myColor.G//
myColor.B//这是对应的三个RGB色彩参数
第2个回答  2008-05-31
Bitmap bitmap = new Bitmap(panel1.Image);
Color myColor = new Color();
myColor = bitmap.GetPixel(1, 1);
myColor.R//
myColor.G//
myColor.B//这是对应的三个RGB色彩参数本回答被提问者采纳
第3个回答  2008-05-30
Bitmap bm1 = new Bitmap("D:\\1.jpg");//得到一个bitmap
bm1.GetPixel(x,y);//取到相应坐标的像素的颜色
相似回答