当前位置:网站首页>VB. Net class library - 4 screen shots, clipping
VB. Net class library - 4 screen shots, clipping
2022-06-26 21:56:00 【Xiaoyu 163】
VB.net use screen Class to screenshot , In fact, there is no need to call api
In class library myScreen Write the function in
''' <summary>
''' Get screen pictures
''' </summary>
''' <returns> screen picture </returns>
Public Function GetScreen()
Dim scr As Screen = Screen.PrimaryScreen
Dim recSc As Rectangle = scr.Bounds
Image = New Bitmap(recSc.Width, recSc.Height)
g = Graphics.FromImage(Image)
g.CopyFromScreen(New Point(0, 0), New Point(0, 0), New Size(recSc.Width, recSc.Height))
Return Image
End Function
''' <summary>
''' This function is mainly used to crop the obtained screen image . Be careful : When calling, the MouseDown To the GDIscr.p1 Pass in the first vertex in .
''' And then MouseUp To the GDIscr.p2 Pass in the second vertex , The vertex style is drawn from the upper left corner to the lower right corner .
''' </summary>
''' <param name="bmp"> Incoming screenshot , But also other pictures </param>
''' <returns> Cut out pictures </returns>
Public Function CutScren(bmp As Bitmap)
g = Graphics.FromImage(bmp)
Dim rc As Rectangle = New Rectangle(p1, New Size(p2.X - p1.X, p2.Y - p1.Y)) ' Starting point, length and width
Image = bmp.Clone(rc, Imaging.PixelFormat.Format32bppArgb)
Return Image
End FunctionWrite... In the class :
Public p1 As Point
Public p2 As PointExpose these two variables : In the main form, you need to call
call :test Create a new form called Cut
Add a picturebox:


![]()
FromBorderStyle Change it to none
WindowState Change it to Maximized,
Cut Write code :
'Imports GDI_Make_NET4_5.myScreen
Public Class Cut
Public GDIscr As New GDI_Make_NET4_5.myScreen
Private ispick As Boolean
Public Sub ShowMe(bmp As Bitmap)
Pic.Location = New Point(0, 0)
Pic.Width = bmp.Width
Pic.Height = bmp.Height
Pic.Image = bmp
ispick = True
Me.Show()
End Sub
Private Sub Pic_MouseDown(sender As Object, e As MouseEventArgs) Handles Pic.MouseDown
If ispick = True Then
GDIscr.p1 = New Point(e.X, e.Y)
End If
End Sub
Private Sub Pic_MouseUp(sender As Object, e As MouseEventArgs) Handles Pic.MouseUp
If ispick = True Then
GDIscr.p2 = New Point(e.X, e.Y)
Pic.Image = GDIscr.CutScren(Pic.Image)
Clipboard.SetImage(Pic.Image)
MsgBox(" Copied to clipboard , Double click the picture to exit ")
ispick = False
End If
End Sub
Private Sub Pic_DoubleClick(sender As Object, e As EventArgs) Handles Pic.DoubleClick
Close()
End Sub
End ClassThe main form uses MouseDown Get the first point ,MouseUp Get the second point and call the function , Pass in myScreen,
ispick The function of the is to prevent errors in secondary cropping , In code msgbox The segment can be modified by itself 、 Or save the picture .
test :
spot screen Get a screenshot of the current screen
Click on cut Show Cut forms , Be careful , Show a form . The first point is the upper left corner of the area you want to select , The second point is the lower right corner of the area you want to select , Just understand the code , If the order of points is reversed, the screenshot , It doesn't show .
边栏推荐
- 财务费用分析怎么分析
- AI智能抠图工具--头发丝都可见
- leetcode:6103. 从树中删除边的最小分数【dfs + 联通分量 + 子图的值记录】
- 指南针能开户炒股吗?安全吗?
- Icml2022 | neurotoxin: a lasting back door to federal learning
- 关于appium踩坑 :Encountered internal error running command: Error: Cannot verify the signature of (已解决)
- Module 5 operation
- Android mediacodec hard coded H264 file (four), ByteDance Android interview
- BN(Batch Normalization) 的理论理解以及在tf.keras中的实际应用和总结
- MacOS环境下使用HomeBrew安装[email protected]
猜你喜欢

Using C to operate SQLSERVER database through SQL statement tutorial

Pass note 【 dynamic planning 】

MATLAB and MySQL database connection and data exchange (based on ODBC)

【图像处理基础】基于matlab GUI图像曲线调整系统【含Matlab源码 1923期】
![Flower shop window layout [dynamic planning]](/img/d9/6b8f9cd0f74e70b313d2571c2ded30.png)
Flower shop window layout [dynamic planning]

Parsing complex JSON in fluent

用C#通过sql语句操作Sqlserver数据库教程

网络爬虫2:抓取网易云音乐评论用户ID及主页地址

Chapter 2 construction of self defined corpus
![[LeetCode]-链表-2](/img/f7/9d4b01285fd6f7fa9f3431985111b0.png)
[LeetCode]-链表-2
随机推荐
Flower shop window layout [dynamic planning]
Data governance does everything
Which securities company is the most convenient, safe and reliable for opening an account
如何在 SAP BTP 平台上启用 HANA Cloud 服务
YOLOv6:又快又准的目标检测框架开源啦
CVPR 2022 - Interpretation of selected papers of meituan technical team
Test comparison of linear model LN, single neural network SNN, deep neural network DNN and CNN
YuMinHong: New Oriental does not have a reversal of falling and turning over, destroying and rising again
Configuring assimp Library in QT environment (MinGW compiler)
Is there any risk in opening a securities registration account? Is it safe?
如何用 SAP BTP 平台上的图形建模器创建一个 OData 服务
MATLAB与Mysql数据库连接并数据交换(基于ODBC)
数据治理啥都干
Unity 设置Material、Shader的方法
Is there any risk in registering and opening an account for stock speculation? Is it safe?
Which securities company is the most convenient, safe and reliable for opening an account
[LeetCode]-链表-2
AI智能抠图工具--头发丝都可见
Netease Yunxin officially joined the smart hospital branch of China Medical Equipment Association to accelerate the construction of smart hospitals across the country
What is the “ How to remove a custom form list?