Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Runtime.InteropServices
- Imports System.Drawing
- Friend Module Win32API
- #Region " Constants & Enums "
- Public Const LR_LOADFROMFILE = &H10
- #Region " TernaryRasterOperations "
- ''' <summary>
- ''' Specifies a raster-operation code. These codes define how the color data for the
- ''' source rectangle is to be combined with the color data for the destination
- ''' rectangle to achieve the final color.
- ''' </summary>
- Public Enum TernaryRasterOperations As UInteger
- ''' <summary>dest = source</summary>
- SRCCOPY = &HCC0020
- ''' <summary>dest = source OR dest</summary>
- SRCPAINT = &HEE0086
- ''' <summary>dest = source AND dest</summary>
- SRCAND = &H8800C6
- ''' <summary>dest = source XOR dest</summary>
- SRCINVERT = &H660046
- ''' <summary>dest = source AND (NOT dest)</summary>
- SRCERASE = &H440328
- ''' <summary>dest = (NOT source)</summary>
- NOTSRCCOPY = &H330008
- ''' <summary>dest = (NOT src) AND (NOT dest)</summary>
- NOTSRCERASE = &H1100A6
- ''' <summary>dest = (source AND pattern)</summary>
- MERGECOPY = &HC000CA
- ''' <summary>dest = (NOT source) OR dest</summary>
- MERGEPAINT = &HBB0226
- ''' <summary>dest = pattern</summary>
- PATCOPY = &HF00021
- ''' <summary>dest = DPSnoo</summary>
- PATPAINT = &HFB0A09
- ''' <summary>dest = pattern XOR dest</summary>
- PATINVERT = &H5A0049
- ''' <summary>dest = (NOT dest)</summary>
- DSTINVERT = &H550009
- ''' <summary>dest = BLACK</summary>
- BLACKNESS = &H42
- ''' <summary>dest = WHITE</summary>
- WHITENESS = &HFF0062
- ''' <summary>
- ''' Capture window as seen on screen. This includes layered windows
- ''' such as WPF windows with AllowsTransparency="true"
- ''' </summary>
- CAPTUREBLT = &H40000000
- End Enum
- #End Region
- #End Region
- #Region " Structures "
- <StructLayout(LayoutKind.Explicit)> Public Structure STRUCT_BITMAP
- <FieldOffset(0)> Public bmType As Int32
- <FieldOffset(4)> Public bmWidth As Int32
- <FieldOffset(8)> Public bmHeight As Int32
- <FieldOffset(12)> Public bmWidthBytes As Int32
- <FieldOffset(16)> Public bmPlanes As Int16
- <FieldOffset(18)> Public bmBitsPixel As Int16
- <FieldOffset(20)> Public bmBits As Int32
- End Structure
- Public Structure CUSTOM_BITMAP
- Dim hBmp As IntPtr
- Dim hDC As IntPtr
- Dim hOld As IntPtr
- Dim Info As STRUCT_BITMAP
- End Structure
- <StructLayout(LayoutKind.Sequential)> _
- Public Structure STRUCT_RECT
- Public left As Int32
- Public top As Int32
- Public right As Int32
- Public bottom As Int32
- End Structure
- #End Region
- #Region " API Methods "
- ''' <summary>
- ''' Performs a bit-block transfer of the color data corresponding to a
- ''' rectangle of pixels from the specified source device context into
- ''' a destination device context.
- ''' </summary>
- ''' <param name="hdc">Handle to the destination device context.</param>
- ''' <param name="nXDest">The leftmost x-coordinate of the destination rectangle (in pixels).</param>
- ''' <param name="nYDest">The topmost y-coordinate of the destination rectangle (in pixels).</param>
- ''' <param name="nWidth">The width of the source and destination rectangles (in pixels).</param>
- ''' <param name="nHeight">The height of the source and the destination rectangles (in pixels).</param>
- ''' <param name="hdcSrc">Handle to the source device context.</param>
- ''' <param name="nXSrc">The leftmost x-coordinate of the source rectangle (in pixels).</param>
- ''' <param name="nYSrc">The topmost y-coordinate of the source rectangle (in pixels).</param>
- ''' <param name="dwRop">A raster-operation code.</param>
- ''' <returns>
- ''' <c>true</c> if the operation succeeded, <c>false</c> otherwise.
- ''' </returns>
- <DllImport("gdi32.dll", ExactSpelling:=True, SetLastError:=True)> _
- Public Function BitBlt(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
- End Function
- <DllImport("gdi32.dll", ExactSpelling:=True, SetLastError:=True)> _
- Public Function CreateCompatibleDC(ByVal hRefDC As IntPtr) As IntPtr
- End Function
- <DllImport("gdi32.dll", ExactSpelling:=True, SetLastError:=True)> _
- Public Function CreateCompatibleBitmap(ByVal hdc As IntPtr, ByVal nWidth As Integer, ByVal nHeight As Integer) As IntPtr
- End Function
- <DllImport("user32.dll", ExactSpelling:=True, SetLastError:=True)> _
- Public Function GetDC(ByVal hwnd As IntPtr) As IntPtr
- End Function
- <DllImport("user32.dll", ExactSpelling:=True, SetLastError:=True)> _
- Public Function ReleaseDC(ByVal hWnd As IntPtr, ByVal hDC As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
- End Function
- <DllImport("gdi32.dll", ExactSpelling:=True, SetLastError:=True)> _
- Public Function SelectObject(ByVal hdc As IntPtr, ByVal hObject As IntPtr) As IntPtr
- End Function
- <DllImport("gdi32.dll", ExactSpelling:=True, SetLastError:=True)> _
- Public Function DeleteObject(ByVal hObject As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
- End Function
- <DllImport("gdi32.dll", ExactSpelling:=True, SetLastError:=True)> _
- Public Function DeleteDC(ByVal hdc As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
- End Function
- 'Public Declare Function LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As Long, ByVal lpsz As String, ByVal un1 As Long, ByVal Width As Long, ByVal Height As Long, ByVal opmode As Long) As Long
- <DllImport("user32.dll", SetLastError:=True)> _
- Public Function LoadImage(ByVal hInst As IntPtr, ByVal lpszName As String, ByVal uType As UInt32, ByVal cxDesired As Integer, ByVal cyDesired As Integer, ByVal fuLoad As UInt32) As IntPtr
- End Function
- 'Public Declare Function GetObject Lib "gdi32" (ByVal hObject As Long, ByVal nCount As Long, ByVal lpObject As IntPtr) As Long
- <DllImport("gdi32.dll", SetLastError:=True)> _
- Public Function GetObject(ByVal hgdiobj As IntPtr, ByVal cbBuffer As Integer, ByVal lpvObject As IntPtr) As Integer
- End Function
- 'Public Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long) As Long
- <DllImport("gdi32.dll", SetLastError:=True)> _
- Public Function GetPixel(ByVal hdc As IntPtr, ByVal nXPos As Integer, ByVal nYPos As Integer) As UInteger
- End Function
- 'Public Declare Function SetPixel Lib "gdi32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
- <DllImport("gdi32.dll", SetLastError:=True)> _
- Public Function SetPixel(ByVal hdc As IntPtr, ByVal nXPos As Integer, ByVal nYPos As Integer, ByVal crColor As Integer) As UInteger
- End Function
- <DllImport("user32.dll")> _
- Public Function FillRect(ByVal hDC As IntPtr, ByRef lprc As STRUCT_RECT, ByVal hbr As IntPtr) As Integer
- End Function
- <DllImport("gdi32.dll")> _
- Public Function CreateSolidBrush(ByVal crColor As UInteger) As IntPtr
- End Function
- #End Region
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement