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

来源:百度知道 编辑:UC知道 时间:2024/05/29 06:30:26
C#中 怎么获得某一个控件中图片的某一点像素的颜色值啊?
比如我要实现
panel1.Image的12,12坐标上的像素的Color (ARGB)的信息

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色彩参数

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

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