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         }

  • 相关阅读:
    Android——另外一种增删查改的方式(ContentProvider常用)
    VS2012下基于Glut OpenGL glScissor示例程序:
    JAXP的SAX解析
    38岁老男孩个人建站方向求教
    [置顶] 某大型银行深化系统技术方案之十三:服务层之服务接口模式
    比特币人必知术语
    ok6410 u-boot-2012.04.01移植二修改源码支持单板
    最近修bug的一点感悟
    小智慧24
    redis beforesleep
  • 原文地址:https://www.cnblogs.com/jf-guo/p/6611070.html
Copyright © 2011-2022 走看看