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
| Enum TernaryRasterOperations As Integer
SRCCOPY = 13369376 'dest = source
SRCPAINT = 15597702 'dest = source OR dest
SRCAND = 8913094 'dest = source AND dest
SRCINVERT = 6684742 'dest = source XOR dest
SRCERASE = 4457256 'dest = source AND (NOT dest )
NOTSRCCOPY = 3342344 'dest = (NOT source)
NOTSRCERASE = 1114278 'dest = (NOT src) AND (NOT dest)
MERGECOPY = 12583114 'dest = (source AND pattern)
MERGEPAINT = 12255782 'dest = (NOT source) OR dest
PATCOPY = 15728673 'dest = pattern
PATPAINT = 16452105 'dest = DPSnoo
PATINVERT = 5898313 'dest = pattern XOR dest
DSTINVERT = 5570569 'dest = (NOT dest)
BLACKNESS = 66 'dest = BLACK
WHITENESS = 16711778 'dest = WHITE
End Enum
Public Declare Function BitBlt Lib "gdi32.dll" (ByVal hdc 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 TernaryRasterOperations) As Boolean
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim G1 As Graphics = Me.CreateGraphics
Dim MyImage As Image = New Bitmap(Me.ClientRectangle.Width, Me.ClientRectangle.Height, G1)
Dim G2 As Graphics = Graphics.FromImage(MyImage)
Dim dc1 As IntPtr = G1.GetHdc()
Dim dc2 As IntPtr = G2.GetHdc()
BitBlt(dc2, 0, 0, Me.ClientRectangle.Width, Me.ClientRectangle.Height, dc1, 0, 0, TernaryRasterOperations.SRCCOPY)
G1.ReleaseHdc(dc1)
G2.ReleaseHdc(dc2)
MyImage.Save("c:\Captured.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
MessageBox.Show("Finished Saving Image")
End Sub |
Partager