新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
實(shí)現(xiàn)VB.NET遠(yuǎn)程控制抓屏+壓縮
VB.NET經(jīng)過(guò)長(zhǎng)時(shí)間的發(fā)展,很多用戶都很了解VB.NET遠(yuǎn)程控制了,我把我的一點(diǎn)點(diǎn)這方面的經(jīng)驗(yàn)和大家分享一下。VB.NET做為VB6的升級(jí)版本,具備了許多新的功能,它可以簡(jiǎn)便快捷地創(chuàng)建 .NET 應(yīng)用程序(包括 XML Web services 和 ASP.NET Web 應(yīng)用程序),還是一個(gè)功能強(qiáng)大的面向?qū)ο蟮木幊陶Z(yǔ)言(如繼承、接口和重載)。

#T#新的語(yǔ)言功能包括自由線程處理和結(jié)構(gòu)化異常處理。VB.NET 還完全集成了.NET 框架和公共語(yǔ)言運(yùn)行庫(kù),.NET 框架和公共語(yǔ)言運(yùn)行庫(kù)共同提供語(yǔ)言互操作性、垃圾回收、增強(qiáng)的安全性和改進(jìn)的版本支持??梢哉f(shuō)是一個(gè)劃時(shí)代的產(chǎn)品!我們來(lái)看看VB.NET遠(yuǎn)程控制實(shí)例[抓屏+壓縮]的小例子。
VB.NET遠(yuǎn)程控制轉(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
新聞標(biāo)題:實(shí)現(xiàn)VB.NET遠(yuǎn)程控制抓屏+壓縮
文章鏈接:http://www.dlmjj.cn/article/dhdjjji.html


咨詢
建站咨詢
