LOGO OA教程 ERP教程 模切知识交流 PMS教程 CRM教程 开发文档 其他文档  
 
网站管理员

C#图片复制、粘贴、打开、保存、取一小块图、抓屏截图

admin
2021年1月20日 11:12 本文热度 2995


      //复制图像
       private void button4_Click(object sender, EventArgs e)
       {
           Clipboard.SetDataObject(pictureBox3.Image);
       }

       //粘贴图像
       private void button5_Click(object sender, EventArgs e)
       {
           IDataObject iData = Clipboard.GetDataObject();
           if (iData.GetDataPresent(DataFormats.Bitmap))
           {
               pictureBox4.Image = (Bitmap)iData.GetData(DataFormats.Bitmap);
           }
       }

       //打开图像
       private void button6_Click(object sender, EventArgs e)
                 
           OpenFileDialog ofdlg = new OpenFileDialog();
           ofdlg.Filter = "BMP File(*.bmp)|*.bmp";
           if (ofdlg.ShowDialog() == DialogResult.OK)
           {
               Bitmap image = new Bitmap(ofdlg.FileName);
               pictureBox4.Image = image;
           }
       }

       //保存图像
       private void button7_Click(object sender, EventArgs e)
       {
           string str;
           Bitmap box1 = new Bitmap(pictureBox4.Image);
           SaveFileDialog sfdlg = new SaveFileDialog();
           sfdlg.Filter = "bmp文件(*.BMP)|*.BMP|All File(*.*)|*.*";
           sfdlg.ShowDialog();
           str = sfdlg.FileName;
           box1.Save(str);
       }

       //取一小块图
       private void button9_Click(object sender, EventArgs e)
       {
           //axPictureClip1.Picture = pictureBox4.Image;
           //axPictureClip1.Cols = 6;//将图片分成6列 axPictureClip1在COM组建里Microsoft Picture Clip Control
           //axPictureClip1.Rows = 3;//将图片分成3行
           //try
           //{
           //   pictureBox5.Image = axPictureClip1.get_GraphicCell(0);//取出一小块
           //}
           //catch(Exception ex)
           //{
           //   MessageBox.Show(ex.ToString());
           //}

           axPictureClip1.Picture = pictureBox4.Image;
           axPictureClip1.ClipX = 15;
           axPictureClip1.ClipY = 15;
           axPictureClip1.ClipHeight = 50;
           axPictureClip1.ClipWidth = 50;
           pictureBox5.Image = axPictureClip1.Clip;//取出一小块
       }

//抓屏截图
private void button15_Click(object sender, EventArgs e)
       {
           Image objImage = new Bitmap(400, 300);
           Graphics g = Graphics.FromImage(objImage);
           g.CopyFromScreen(new Point(Cursor.Position.X - 150, Cursor.Position.Y - 25),new Point(0, 0), new Size(400, 300));
           IntPtr dc1 = g.GetHdc();
           g.ReleaseHdc(dc1);
           this.pictureBox1.Image = objImage;
           objImage.Save("e:\\test.jpg");
       }

该文章在 2021/1/20 11:12:02 编辑过
关键字查询
相关文章
正在查询...
点晴ERP是一款针对中小制造业的专业生产管理软件系统,系统成熟度和易用性得到了国内大量中小企业的青睐。
点晴PMS码头管理系统主要针对港口码头集装箱与散货日常运作、调度、堆场、车队、财务费用、相关报表等业务管理,结合码头的业务特点,围绕调度、堆场作业而开发的。集技术的先进性、管理的有效性于一体,是物流码头及其他港口类企业的高效ERP管理信息系统。
点晴WMS仓储管理系统提供了货物产品管理,销售管理,采购管理,仓储管理,仓库管理,保质期管理,货位管理,库位管理,生产管理,WMS管理系统,标签打印,条形码,二维码管理,批号管理软件。
点晴免费OA是一款软件和通用服务都免费,不限功能、不限时间、不限用户的免费OA协同办公管理系统。
Copyright 2010-2025 ClickSun All Rights Reserved