Read Pixel from Screen ( using VB.NET)

VB.NET Windows Application

If someone clicks on a pixel on a screen how can the pixel color be read e.g. in Mouse down event

Is it possible to access the screen as a bitmap? i.e. copy a specific area of the screen content into a bitmap.

Arvind

LVL 5
arvindb1Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
rovermCommented:
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Bob LearnedCommented:
Get the color of a pixel from a picture box image:

      Dim bm As Bitmap = Me.PictureBox1.Image
      bm.GetPixel(x, y)
0
 
iboutchkineCommented:
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
        'get the picture box's bitmap into the "bitmap " variable
        Dim bitmap As Bitmap = PictureBox1.Image
        'get the color at the X,Y position, using the event (e) object
        Dim color As Color = bitmap.GetPixel(e.X, e.Y)
        'get the RGB value
        Dim ColorValue As Integer = color.ToArgb

        'extract the red, and set the form's caption
        Me.Text = "Red = " & CStr((ColorValue And &HFF0000) \ &H10000) & _
        " Green = " & CStr((ColorValue And &HFF0000) \ &H100) & _
        " Blue = " & CStr((ColorValue And &HFF0000) \ &H1)
    End Sub
0
 
Bob LearnedCommented:
Is this still an open issue?
0
 
arvindb1Author Commented:
Yes, Currently i'm analyzing proposed solutions, pls. give me some time. i'll definitely get back.
Thanks
Arvind
0
 
arvindb1Author Commented:
Comment from testn has solved my problem
Thanks for help
Arvind
0
All Courses

From novice to tech pro — start learning today.