110,536
社区成员
发帖
与我相关
我的任务
分享
public Form1()
{
InitializeComponent();
pictureBox1.Load("https://img-bbs.csdn.net/upload/201709/09/1504950712_417395.jpg");
pictureBox2.Load("https://img-bbs.csdn.net/upload/201709/09/1504950719_93346.png");
//var g = Graphics.FromImage(pictureBox2.Image);
//g.DrawRectangle(Pens.Red, new Rectangle(60, 10, 410, 100));
var d1 = new Dictionary<Color, int>();
var m = (410 - 60) * (100 - 10);
var num1 = 0;
var num2 = 0;
for (var x = 60; x < 410; x++)
{
for (var y = 10; y < 100; y++)
{
if ((pictureBox1.Image as Bitmap).GetPixel(x, y).GetBrightness() < 0.2) num1++;
if ((pictureBox2.Image as Bitmap).GetPixel(x, y).GetBrightness() < 0.2) num2++;
}
}
label1.Text = string.Format("{0} {1}",m, num1);
label2.Text = string.Format("{0} {1}",m, num2);
}