【发布时间】:2015-12-31 17:04:02
【问题描述】:
我正在对屏幕截图项目进行图像检测,我尝试了很多方法让我的程序找到图像,并且我在许多论坛上阅读了很多帖子,但没有一个是有效的。
现在我正在尝试将位图转换为散列并与其他图像散列匹配,如果会有一些相似之处,我会知道屏幕截图上是否有我的图像。但是我在将位图转换为哈希时遇到了问题。 这是我的代码:
Bitmap ScreenShot = new Bitmap(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
Graphics g = Graphics.FromImage(ScreenShot);
g.CopyFromScreen(Point.Empty, Point.Empty, Screen.PrimaryScreen.WorkingArea.Size);
pictureBox1.Image = ScreenShot;
pictureBox1.Size = Screen.PrimaryScreen.WorkingArea.Size;
System.Drawing.ImageConverter ic = new System.Drawing.ImageConverter();
byte[] SS = new byte[1];
SS = (byte[])ic.ConvertTo(ScreenShot, SS.GetType());
SHA256Managed hash = new SHA256Managed();
byte[] hash1 = hash.ComputeHash(SS);
textBox1.Text = hash1.ToString();
这就是文本框显示的内容:System.Byte[]
【问题讨论】: