/// <summary>
/// 复制屏幕到内存中
/// </summary>
/// <returns>返回内存流</returns>
public static MemoryStream GetScreenPng()
{
Screen sc = Screen.PrimaryScreen;//取得主屏 Rectangle rct = sc.Bounds;//得到主屏的范围
Image img = new Bitmap(rct.Width, rct.Height);
Graphics gp = Graphics.FromImage(img);
gp.CopyFromScreen(new Point(, ), new Point(, ), new Size(rct.Width, rct.Height)); //SolidBrush sb = new SolidBrush(Color.Red);
//Font ft = new System.Drawing.Font("黑体",16); //gp.DrawString("这是什么",ft,sb,new PointF(0,rct.Height-ft.Height));
//img.Save(@"d:\截图.png"); MemoryStream stream = new MemoryStream();
img.Save(stream, System.Drawing.Imaging.ImageFormat.Png);//转化为流,此时就已经有了png格式符了 return stream; }