https://barnamenevis.org/showpo...4&postcount=91
<DllImport("user32.dll")> _
Shared Function GetDC(ByVal hWnd As IntPtr) As IntPtr
End Function
<DllImport("user32.dll")> _
Shared Function ReleaseDC(ByVal hWnd As IntPtr, ByVal hDC As IntPtr) As Integer
End Function
<DllImport("gdi32.dll")> _
Shared Function GetPixel(ByVal hDC As IntPtr, ByVal x As Integer, ByVal y As Integer) As Integer
End Function
<DllImport("gdi32.dll")> _
Shared Function SetPixel(ByVal hDC As IntPtr, ByVal x As Integer, ByVal y As Integer, ByVal color As Integer) As Integer
End Function
Public Shared Function GetPixel(ByVal control As Control, ByVal x As Integer, ByVal y As Integer) As Color
Dim color As Color = color.Empty
If Not control Is Nothing Then
Dim hDC As IntPtr = GetDC(control.Handle)
Dim colorRef As IntPtr = GetPixel(hDC, x, y)
color = color.FromArgb((colorRef.ToInt32 & &HFF) Or (colorRef.ToInt32 & &HFF00 >> 8) Or (colorRef.ToInt32 & &HFF0000 >> 16))
ReleaseDC(control.Handle, hDC)
End If
Return color
End Function
Public Shared Sub SetPixel(ByVal control As Control, ByVal x As Integer, ByVal y As Integer, ByVal color As Color)
If Not control Is Nothing Then
Dim hDC As IntPtr = GetDC(control.Handle)
Dim argb As Integer = color.ToArgb()
Dim colorRef As Integer = ((argb & &HFF0000) >> 16) Or (argb & &HFF00) Or ((argb & &HFF) << 16)
SetPixel(hDC, x, y, colorRef)
ReleaseDC(control.Handle, hDC)
End If
End Sub