zoukankan      html  css  js  c++  java
  • C#实现屏幕指定区域截屏

                //string Opath = @"C:/Picture";
                //if (Opath.Substring(Opath.Length - 1, 1) != @"/")
                   //Opath = Opath + @"/";
                //string photoname = DateTime.Now.Ticks.ToString();
                //string path1 = Opath + DateTime.Now.ToShortDateString();
                //if (!Directory.Exists(path1))
                    //Directory.CreateDirectory(path1);搜索

    1           //截取全屏图象
    2         private void btnFullScreen_Click(object sender, EventArgs e)

    3        {

    4             //创建图象,保存将来截取的图象
    5             Bitmap image = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);

    6             Graphics imgGraphics = Graphics.FromImage(image);

    7             //设置截屏区域 柯乐义
    8             imgGraphics.CopyFromScreen(0, 0, 0, 0, new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height));

    9             //保存
    10           SaveImage(image);

    11 }

    12
    13 //保存图象文件
    14         private void SaveImage(Image image)

    15         {

    16             if (saveFileDialog.ShowDialog(this) == DialogResult.OK)

    17             {

    18                 string fileName = saveFileDialog.FileName;

    19                 string extension = Path.GetExtension(fileName);

    20                 if (extension == ".jpg")

    21                  {

    22                       image.Save(fileName, ImageFormat.Jpeg);

    23                   }

    24                 else
    25                  {

    26                        image.Save(fileName, ImageFormat.Bmp);

    27                  }

    28            }

    29         }

  • 相关阅读:
    Kotlin Coroutines不复杂, 我来帮你理一理
    Refresh design pattern
    Android App安装包瘦身计划
    Google IO 2019 Android 太长不看版
    Effective Java读书笔记完结啦
    探究高级的Kotlin Coroutines知识
    移动应用中的非功能性(跨职能)需求
    Android程序员的Flutter学习笔记
    如何正确使用Espresso来测试你的Android程序
    MVP模式, 开源库mosby的使用及代码分析
  • 原文地址:https://www.cnblogs.com/jf-guo/p/6611070.html
Copyright © 2011-2022 走看看