c# 语句实现屏幕抓图

来源:互联网 发布:js md5加密例子 编辑:程序博客网 时间:2024/04/30 05:33

抓图 需要的DLL
using System.Drawing;
using System.Drawing.Imaging;

//再经过8句将位图变换成整形数组矩阵。可以最大限度的提高图像处理速度。
比 myBitmap.GetPixel(???)方法快100倍以上速度与C++指针操作不相上下。

//获得图像
Rectangle rec = new Rectangle(0, 0, myBitmap.Width, myBitmap.Height);
BitmapData bmpData = myBitmap.LockBitsrec,ImageLockMode.ReadWrite,PixelFormat.Format32bppPArgb);        

//将图像变换    
IntPtr scan0 = bmpData.Scan0;
int len = myBitmap.Width * myBitmap.Height;
int[] pixels = new int[len];
Marshal.Copy(scan0, pixels, 0, len);
myBitmap.UnlockBits(bmpData);
myBitmap.Dispose();

DelegateShowLabelstr dc1 = new DelegateShowLabelstr(ShowLabelstr);
DelegateShowLabelstrgz("处理完成", dc1); //回调其他线程 

 

转致:http://community.csdn.net/Expert/topic/5234/5234215.xml?temp=.2225763