|
-
Mar 10th, 2008, 06:08 PM
#1
Thread Starter
Fanatic Member
[2005] Get a Pixel Color of a point in a screen
Hi!!
I want to get the pixel color of the screen, in determinated point. I'm correnctly taking a screenshot and getting the information from there, but that takes a lot of time, and i need to have the information every 10 ms without putting to much load on the cumputer. Can you help me?
-
Mar 11th, 2008, 06:39 AM
#2
Re: [2005] Get a Pixel Color of a point in a screen
Code:
Dim c as Color
c = Image.GetPixel(x, Y)
Should be as simple as that
-
Mar 11th, 2008, 12:01 PM
#3
Thread Starter
Fanatic Member
Re: [2005] Get a Pixel Color of a point in a screen
just one problem. Where u put Image. that image was to refer to the screen image.
-
Mar 11th, 2008, 04:53 PM
#4
Re: [2005] Get a Pixel Color of a point in a screen
Replace file here with the path to your screen shot taken 
Code:
Dim bitmap As New Bitmap("file here")
Dim c As Color = bitmap.GetPixel(x, y)
-
Mar 12th, 2008, 09:45 AM
#5
Thread Starter
Fanatic Member
Re: [2005] Get a Pixel Color of a point in a screen
that i know how to do! Let me explain better:
If u dont have any window open u just see ur windows background image (wallpaper), if you have lets Firefox open u see the colors of the site you are in, right?
Well i want to get the pixel color of the point x, y of the screen. The screen here means whatever you have top most in that point in windows. I hope i explained well now
-
Nov 11th, 2008, 04:23 AM
#6
Addicted Member
Re: [2005] Get a Pixel Color of a point in a screen
Bump, I've been needing the same thing for centuries, just never found out how. I wonder it it's even possible to do? Is there a class to get the current screen as a bitmap and then do the pixel analysis?
-
Nov 11th, 2008, 06:20 AM
#7
Re: [2005] Get a Pixel Color of a point in a screen
When you want to do something impossible in GDI+, use the Graphics.CopyFromScreen method. (The first argument, Source, is the screen coordinate of the point you want to capture, and the second one, Destination, is the graphics coordinate of where you want to copy the point to. They forgot to tell you that in the help files.)
Here's a little working example I rustled up on a default Form. It reports the ARGB color value of any point on the screen in the Form's title bar. This technique captures only a single pixel, so probably it won't add too much CPU load. On my system it reports a CPU usage ranging from 2 to 8% when running from VS2008 Express.
Code:
Public Class Form1
Private WithEvents timer1 As New Windows.Forms.Timer
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
timer1.Interval = 10
timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles timer1.Tick
Using bmp As New Bitmap(1, 1)
Using g As Graphics = Graphics.FromImage(bmp)
g.CopyFromScreen(Windows.Forms.Cursor.Position, _
New Point(0, 0), New Size(1, 1))
End Using
Me.Text = bmp.GetPixel(0, 0).ToString
Me.Invalidate()
End Using
End Sub
End Class
all the best, BB
Last edited by boops boops; Nov 11th, 2008 at 06:37 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|