1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| Public Class Form1
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Declare Auto Function BitBlt Lib "GDI32.DLL" (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 Int32) As Boolean
Dim image
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim xdeb, xfin, ydeb, yfin As Integer
Dim g1 As Graphics = Graphics.FromHwnd(GetDesktopWindow)
Dim k As Integer
xdeb = 0
ydeb = 0
xfin = 100
yfin = 100
image = New Bitmap(xfin - xdeb + 1, yfin - ydeb + 1, g1)
Dim g2 As Graphics = Graphics.FromImage(image)
Dim dc1 As IntPtr = g1.GetHdc
Dim dc2 As IntPtr = g2.GetHdc
' Parametres
Dim Stopwatch As System.Diagnostics.Stopwatch
Stopwatch = New Stopwatch
' Initialisation : debut de la mesure
Stopwatch.Start()
For k = 0 To 100
BitBlt(dc2, 0, 0, xfin - xdeb + 1, yfin - ydeb + 1, dc1, xdeb, ydeb, 13369376)
Next k
Stopwatch.Stop()
' Affichage de la mesure
MessageBox.Show(Stopwatch.Elapsed().TotalSeconds & " secondes")
PictureBox1.Image = image
g1.ReleaseHdc(dc1)
g2.ReleaseHdc(dc2)
End Sub
End Class |
Partager