C#中的屏幕图像 [英] Screen Image in C#

查看:132
本文介绍了C#中的屏幕图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要用C#创建一个应用程序,当同一屏幕的某些部分发生更改时,该应用程序会捕获屏幕的一部分.谢谢大家.

Hi, I need to create an application in C# that captures part of the screen when certain part of the same screen changes. Thank you all.

推荐答案


从您的问题中得出的想法是,在每个恒定的时间段内进行多次屏幕捕获,并比较逐像素拍摄的图像,以选择更改并捕获的屏幕部分.



the idea from your problem takes multiple screen capture every constant time period and compare the images which taken pixel by pixel to select the part of screen was changed and captured it


Bitmap image1;
Bitmap image2;
Graphics gr;
private void Captures_Images()
{
    Bitmap image1 = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
    Graphics gr = Graphics.FromImage(image1);
    gr.CopyFromScreen(0, 0, 0, 0, image1.Size);
    gr = null;
    pictureBox1.Image = image1;


    // Here Break Time Between Captured

    Bitmap image2 = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
    gr = Graphics.FromImage(image2);
    gr.CopyFromScreen(0, 0, 0, 0, image2.Size);
    gr = null;
    pictureBox1.Image = image2;
}
void Compare_Images(Bitmap b1,Bitmap b2)
{
    int width = b1.Width;
    int height = b1.Height;
    for (int w = 0; w < width; w++)
    {
        for (int h = 0; h < height; h++)
        {
            if ((b1.GetPixel(w, h).A != b2.GetPixel(w, h).A) ||
                (b1.GetPixel(w, h).R != b2.GetPixel(w, h).R) ||
                (b1.GetPixel(w, h).G != b2.GetPixel(w, h).G) ||
                (b1.GetPixel(w, h).B != b2.GetPixel(w, h).B))
            {
                // Changed Bounds Start
            }
        }
    }
}


也许是此处 [ ^ ]可以提供帮助.
Maybe something here[^] can help.


您在屏幕截图上看到了我的文章吗?

http://www.codeproject.com/Articles/91487/Screen- Capture-in-WPF-WinForms-Application.aspx [ ^ ]

我还为您提供了带有本文的示例应用程序.
Did you see my article on screen capture.

http://www.codeproject.com/Articles/91487/Screen-Capture-in-WPF-WinForms-Application.aspx[^]

I have also provided you a sample application with my article.


这篇关于C#中的屏幕图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆