Ich habe gerade mal langeweile gehabt und was gebastelt. Ist aber unter .Net
Also bei dem SSTab Control zeigt er mit folgende Werte an.
Alpha Kanal 255
Rot Anteil 236
Gruen Anteil 233
Blau Anteil 216
Falls du so etwas noch einmal brauchst. Erstelle eine Form unter VB.Net, packe da eine Picturebox drauf. Dazu 2 Labels
Label1 -> Text = Farbe
Label2 -> Nichts machen
Picturebox1 -> Autosize auf Zoom stellen und Anchor Eigenschaft einstellen.
Dann einfach folgenden Source in die Form kopieren
Public Class Form1
Private Sub Button1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim b As New Bitmap(SystemInformation.VirtualScreen.Width, SystemInformation.VirtualScreen.Height)
Dim g As Graphics = Graphics.FromImage(b)
g.CopyFromScreen(0, 0, 0, 0, b.Size)
g.Dispose()
PictureBox1.Image = b
End Sub
Private Sub PictureBox1\_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
Try
Dim p As Point = Nothing
Dim Color As Color = GetColorFromPoint.GetColor(PictureBox1, e, p)
Label2.BackColor = Color
Label2.Text = Color.ToString
Catch ex As Exception
MessageBox.Show(ex.Message.ToString(), "Info")
End Try
End Sub
End Class
Public Class GetColorFromPoint
Public Shared Function GetColor(ByVal pb As System.Windows.Forms.PictureBox, \_
ByVal e As System.Windows.Forms.MouseEventArgs, \_
ByRef Position As Point) As Color
Dim hBitmap As Bitmap = Nothing
Try
hBitmap = New Bitmap(1, 1)
Using g As Graphics = Graphics.FromImage(hBitmap)
With g
.CopyFromScreen(pb.PointToScreen(e.Location), New Point(0, 0), hBitmap.Size)
Position = e.Location()
Dim Color As Color = hBitmap.GetPixel(0, 0)
Return Color
End With
End Using
Catch ex As Exception
MessageBox.Show(ex.Message.ToString(), "Info")
Finally
If hBitmap IsNot Nothing Then hBitmap.Dispose()
End Try
End Function
End Class
MfG Alex