zoukankan      html  css  js  c++  java
  • Screen print or copy

    1.Print screen

    View Code
    Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim memoryImage As Bitmap
    Dim myGraphics As Graphics = Me.CreateGraphics()
    Dim s As Size = New Size(1280, 1024)
    memoryImage = New Bitmap(s.Width, s.Height, myGraphics)
    Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage)
    memoryGraphics.CopyFromScreen(0, 0, 0, 0, s)
    If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then

    memoryImage.Save(SaveFileDialog1.FileName & ".jpg")
    End If

    End Sub


    End Class


    2.Copy screen

    View Code
     1 using System;
    2 using System.Collections.Generic;
    3 using System.ComponentModel;
    4 using System.Data;
    5 using System.Drawing;
    6 using System.Text;
    7 using System.Windows.Forms;
    8 using System.Diagnostics;
    9
    10 namespace copyScreen
    11 {
    12 public delegate void copyToFatherTextBox(Rectangle r);
    13
    14 public partial class Form1 : Form
    15 {
    16 public Form1()
    17 {
    18 InitializeComponent();
    19 }
    20 /*开始截图*/
    21 private void button1_Click(object sender, EventArgs e)
    22 {
    23 ScreenForm screen = new ScreenForm();
    24 screen.copytoFather += new copyToFatherTextBox(copytoTextBox);
    25 screen.ShowDialog();
    26 }
    27 /*截图后续操作*/
    28 public void copytoTextBox(Rectangle rec)
    29 {
    30 Rectangle rec2=rec; //改造一下,去掉红色边框
    31 if(rec.Width>2&&rec.Height>2)
    32 rec2= new Rectangle(rec.X + 1, rec.Y + 1, rec.Width - 2, rec.Height - 2);
    33 Rectangle r = Screen.PrimaryScreen.Bounds;
    34 Image img = new Bitmap(rec2.Width, rec2.Height);
    35 Graphics g = Graphics.FromImage(img);
    36 g.CopyFromScreen(rec2.Location, new Point(0, 0), rec2.Size);
    37 Clipboard.SetDataObject(img, false);
    38 richTextBox1.Paste();
    39 }
    40
    41
    42 }
    43 }



  • 相关阅读:
    git打补丁、还原补丁
    mysql 查两个表相同的值
    系统更新后vs2012无法打开方案资源管理器
    Node.js之Buffer
    html元素固定
    在windows上用netsh动态配置端口转发
    Git忽略规则及.gitignore规则不生效的解决办法
    MySQL5.7.10 初始化失败error
    Nginx和PHP-FPM的启动、重启、停止脚本分享
    centos添加nginx为系统服务
  • 原文地址:https://www.cnblogs.com/songrun/p/2219848.html
Copyright © 2011-2022 走看看