lookup the color of a pixel

Greetings,

I need to get the color of a pixel in a window that does not necessarily have a canvas object. This use to work: currentColor=tabletop.graphics.pixel(x,y).
The pixel may be within any number of canvases or objects. Jason K offered a partial solution. He used the following

dim s as new Shell
s.Execute “screencapture -c -x”
s.Close
dim clip as new Clipboard
dim p as picture = clip.Picture
clip.Close
dim rgbs as RGBSurface = p.RGBSurface
dim c as color = rgbs.Pixel(x, y)
'Break //c is the color under the mouse

theColor = c

maybe there is an easier way?

Thanks!

CG

You could use something like

[code]dim p as new picture(tabletop.width, tabletop.height)
tabletop.Drawinto(p.graphics, 0, 0)
dim rgbs as RGBSurface = p.RGBSurface
dim c as color = rgbs.Pixel(x, y)
'Break //c is the color under the mouse

theColor = c[/code]

if you need color from canvas, you’d better draw into a picture first and show picture in canvas.
That way you can query the picture for the color.
Without going through a screenshot.