Private Declare Function GetCursorPos Lib "user32" Alias "GetCursorPos" (ByRef lpPoint As System.Drawing.PointF) As Integer Private Declare Function GetDC Lib "user32" (ByVal hwnd As IntPtr) As Integer Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Integer, ByVal x As Single, ByVal y As Single) As Integer Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick 'position Dim p As System.Drawing.PointF GetCursorPos(p) 'couleur Dim iCol As Integer = GetPixel(GetDC(IntPtr.Zero), p.X, p.Y) 'applique en forçant l'alpha PictureBox3.BackColor = System.Drawing.Color.FromArgb(255, Convert.ToInt16(&HFF& And iCol), Convert.ToInt16((&HFF00& And iCol) \ 256), (&HFF0000 And iCol) \ 65536) End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionpicture_couleurdelazone.BackColor = System.Drawing.Color.FromArgb(pixel.red, pixel.green, pixel.blue)
Private Declare Function GetDC Lib "user32" (ByVal hwnd As IntPtr) As Integer Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Integer, ByVal x As Integer, ByVal y As Integer) As Integer Public Structure Couleur Dim red As Integer Dim green As Integer Dim blue As Integer End Structure Public Function CouleurPixel(ByVal x As Long, ByVal y As Long) As Couleur Dim pixel As Couleur, RGBPx As Long RGBPx = GetPixel(GetDC(0&), x, y) 'a verifier pixel.red = &HFF& And RGBPx pixel.green = (&HFF00& And RGBPx) \ 256 pixel.blue = (&HFF0000 And RGBPx) \ 65536 CouleurPixel = pixel End Function Private Sub search_pixel() Dim pixel As Couleur pixel = CouleurPixel(X, Y) picture_BDD.BackColor = System.Drawing.Color.FromArgb(pixel.red, pixel.green, pixel.blue) ' probléme ICI End Sub
'position Dim p As System.Drawing.PointF GetCursorPos(p) 'couleur Dim iCol As Integer = GetPixel(GetDC(IntPtr.Zero), X, Y) 'applique en forçant l'alpha PictureBox1.BackColor = System.Drawing.Color.FromArgb(255, Convert.ToInt16(&HFF& And iCol), Convert.ToInt16((&HFF00& And iCol) \ 256), (&HFF0000 And iCol) \ 65536)