Hallo,
ich bin ziemlich neu im Bereich VB.NET. Nun habe ich folgendes Problem:
Ich möchte aus einer ImageBox die Farbe eines Pixels bestimmen. Bisher mache ich das so:
Allerdings bringt das zwei Probleme mit sich:
ich bin ziemlich neu im Bereich VB.NET. Nun habe ich folgendes Problem:
Ich möchte aus einer ImageBox die Farbe eines Pixels bestimmen. Bisher mache ich das so:
VB.NET-Quellcode
- 'get the pixel color
- Using bmpOnePixel As New Bitmap(1, 1)
- 'copy the pixel at the mouse position into the bitmap
- Using gB As Graphics = Graphics.FromImage(bmpOnePixel)
- 'gB.CopyFromScreen(MousePosition, New Point(0, 0), New Size(1, 1))
- Dim gImg As Graphics
- gImg = imgBox.CreateGraphics()
- gImg.CopyFromScreen(x + Me.Location.X + 16, y + Me.Location.Y + 38, x + Me.Location.X + 16, y + Me.Location.Y + 38, New Size(1, 1))
- End Using
- 'get the color of the captured pixel
- R = bmpOnePixel.GetPixel(0, 0).R
- G = bmpOnePixel.GetPixel(0, 0).G
- B = bmpOnePixel.GetPixel(0, 0).B
- End Using
Allerdings bringt das zwei Probleme mit sich:
- Sobald der Rahmen nicht genau so dick ist, wie bei meinen Tests, ist das Bild verschoben
- Das ganze Konstrukt ist unglaublich langsam. Ich rufe die Funktion bis zu ungefähr 60.000mal auf; das dauert
Twitch Viewer Display Chat-, Zuschauer- und Statistiktool für Streamer