您好,登錄后才能下訂單哦!
這篇文章主要講解了“VB.NET遠程控制抓屏+壓縮的實現(xiàn)方法”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“VB.NET遠程控制抓屏+壓縮的實現(xiàn)方法”吧!
VB.NET經(jīng)過長時間的發(fā)展,很多用戶都很了解VB.NET遠程控制了,我把我的一點點這方面的經(jīng)驗和大家分享一下。VB.NET做為VB6的升級版本,具備了許多新的功能,它可以簡便快捷地創(chuàng)建 .NET 應(yīng)用程序(包括 XML Web services 和 ASP.NET Web 應(yīng)用程序),還是一個功能強大的面向?qū)ο蟮木幊陶Z言(如繼承、接口和重載)。
新的語言功能包括自由線程處理和結(jié)構(gòu)化異常處理。VB.NET 還完全集成了.NET 框架和公共語言運行庫,.NET 框架和公共語言運行庫共同提供語言互操作性、垃圾回收、增強的安全性和改進的版本支持??梢哉f是一個劃時代的產(chǎn)品!我們來看看VB.NET遠程控制實例[抓屏+壓縮]的小例子。
VB.NET遠程控制轉(zhuǎn)化后代碼如下:
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遠程控制抓屏+壓縮的實現(xiàn)方法”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對VB.NET遠程控制抓屏+壓縮的實現(xiàn)方法這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關(guān)知識點的文章,歡迎關(guān)注!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。