C# 使用光标获取图片框中的像素?

标签 c# winforms bitmap picturebox mouse-cursor

<分区>

如何使用光标在图片框中获取像素 xy

最佳答案

如果想获取被点击像素的颜色:

Color pixelColor;

// add the mouse click event handler in designer mode or:
// myPicturebox.MouseClick += new MouseEventHandler(myPicturebox_MouseClick);
private void myPicturebox_MouseClick(object sender, MouseEventArgs e) {
   if (e.Button == MouseButtons.Left) 
      pixelColor = GetColorAt(e.Location);
}

private Color GetColorAt(Point point) {
   return ((Bitmap)myPicturebox.Image).GetPixel(point.X, point.Y);
}

关于C# 使用光标获取图片框中的像素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10048331/

相关文章:

c# - 将字典字符串字符串转换为json字符串

Android:位图缩小质量低

c# - 使用 Lockbits 替换图像的颜色

c# - 以编程方式将天 (1-31) 绑定(bind)到下拉列表,并将 0 绑定(bind)到天 < 10?

C# 最佳实践 - 计算每个日期出现的次数

C# 引用 WPF 中的 Grid 来更改属性

c# - 打开文件所在位置

c# - 使用 backgroundworker 进行时间控制

c# - 使用 C# 更新 MySQL 中的值数据库

java - 从 ImageView 获取图像并使用编码位图将此图像发送到其他 fragment