这篇文章主要讲解了“VB.NET远程控制抓屏+压缩的实现方法”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“VB.NET远程控制抓屏+压缩的实现方法”吧!
VB.NET经过长时间的发展,很多用户都很了解VB.NET远程控制了,我把我的一点点这方面的经验和大家分享一下。VB.NET做为VB6的升级版本,具备了许多新的功能,它可以简便快捷地创建 .NET 应用程序(包括 XML Web services 和 ASP.NET Web 应用程序),还是一个功能强大的面向对象的编程语言(如继承、接口和重载)。
新的语言功能包括自由线程处理和结构化异常处理。VB.NET 还完全集成了.NET 框架和公共语言运行库,.NET 框架和公共语言运行库共同提供语言互操作性、垃圾回收、增强的安全性和改进的版本支持。可以说是一个划时代的产品!我们来看看VB.NET远程控制实例[抓屏+压缩]的小例子。
VB.NET远程控制转化后代码如下:
Imports System
Imports System.Text
Imports System.Drawing.Imaging
Imports System.IO
Imports System.Drawing
Imports System.Windows.Forms
Namespace Lob.Windows
Public Class ScreenCapture
Private Declare Function BitBlt Lib "GDI32" (ByVal hdcDest As IntPtr, ByVal nXDest As Integer, ByVal nYDest As Integer,
ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hdcSrc As IntPtr, ByVal nXSrc As Integer, ByVal nYSrc As Integer,
ByVal dwRop As Integer) As Boolean
Private Declare Function CreateDC Lib "GDI32" (ByVal lpszDriver As String, ByVal lpszDevice As String,
ByVal lpszOutput As String, ByVal lpInitData As IntPtr) As IntPtr
Public Shared Function Capture() As Image
Dim dc1 As IntPtr = CreateDC("DISPLAY", Nothing, Nothing, CType(Nothing, IntPtr))
Dim g1 As GraphicsGraphics = Graphics.FromHdc(dc1)
Dim ScreenImage As Bitmap = New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, g1)
Dim g2 As GraphicsGraphics = Graphics.FromImage(ScreenImage)
Dim dc3 As IntPtr = g1.GetHdc
Dim dc2 As IntPtr = g2.GetHdc
BitBlt(dc2, 0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, dc3, 0, 0, 13369376)
g1.ReleaseHdc(dc3)
g2.ReleaseHdc(dc2)
Dim bmp As Image = MakeThumbnail(ScreenImage, (ScreenImage.Width * (3 / 4)), (ScreenImage.Height * (3 / 4)))
Return bmp
End Function
Public Shared Function MakeThumbnail(ByVal originalImage As Image, ByVal towidth As Integer, ByVal toheight As Integer) As Image
Dim x As Integer = 0
Dim y As Integer = 0
Dim ow As Integer = originalImage.Width
Dim oh As Integer = originalImage.Height
Dim bitmap As System.Drawing.Image = New System.Drawing.Bitmap(towidth, toheight)
Dim g As SystemSystem.Drawing.Graphics = System.Drawing.Graphics.FromImage(bitmap)
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed
g.Clear(System.Drawing.Color.Transparent)
g.DrawImage(originalImage, New System.Drawing.Rectangle(0, 0, towidth, toheight), New System.Drawing.Rectangle(x, y, ow, oh),
System.Drawing.GraphicsUnit.Pixel)Return bitmap
End Function
End Class
End Namespace
感谢各位的阅读,以上就是“VB.NET远程控制抓屏+压缩的实现方法”的内容了,经过本文的学习后,相信大家对VB.NET远程控制抓屏+压缩的实现方法这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。