/// <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(0, 0), new Point(0, 0), 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;

        }

 

相关文章:

  • 2022-01-01
  • 2021-09-06
  • 2022-12-23
  • 2023-02-05
  • 2021-12-15
  • 2021-12-25
  • 2021-12-05
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-31
  • 2021-09-10
  • 2022-12-23
相关资源
相似解决方案