Get Pixel From Screen and Get the Name of the Pixel Color - Visual Basic .NET

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

In this tutorial Ill show you how to get a color of a pixel that the mouse is pointing at and the name of the pixel color:

For this tutorial you need a picture box, a timer and a textbox:

Set the timer interval to 1 from the properties and set the enable property to True:

Then double click on the timer and the following code:

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim a As New Drawing.Bitmap(1, 1)
        Dim b As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(a)
        b.CopyFromScreen(New Drawing.Point(MousePosition.X, MousePosition.Y), New Drawing.Point(0, 0), a.Size)
        Dim c As Drawing.Color = a.GetPixel(0, 0)
        PictureBox1.BackColor = c
        TextBox1.Text = PictureBox1.BackColor.Name
    End Sub

Share This

Home | About | Contact | Privacy Policy

Copyright 2017 - All Rights Reserved.