471,627 Members | 2,034 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

Get colour of pixel at coordinate

Hi, ive got an imagine in a PictureBox, and would like to get the colour
of the pixel when the mouse is over the control. From what ive (briefly)
seen, there is no way to do this directly in C# and requires you to use
GetPixel from the Win API?

Is this correct? Any other better ways of doing this?

Thanks,
Feb 21 '06 #1
3 2811
Mark Ingram wrote:
Hi, ive got an imagine in a PictureBox, and would like to get the colour
of the pixel when the mouse is over the control. From what ive (briefly)
seen, there is no way to do this directly in C# and requires you to use
GetPixel from the Win API?

Is this correct? Any other better ways of doing this?

Thanks,


I should perhaps say that the pixels in question are inside an image in
a PictureBox.

Thanks,
Feb 21 '06 #2
Assuming that you're image is represented as a Bitmap type, you can use the
GetPixel method. So in your case, you can cast the Image property of the
PictureBox to a Bitmap and then call the GetPixel method, assuming that the
Image property is not null.
http://msdn.microsoft.com/library/de...pixeltopic.asp

--
Tim Wilson
..NET Compact Framework MVP

"Mark Ingram" <no****@nowhere.com> wrote in message
news:u6**************@TK2MSFTNGP14.phx.gbl...
Hi, ive got an imagine in a PictureBox, and would like to get the colour
of the pixel when the mouse is over the control. From what ive (briefly)
seen, there is no way to do this directly in C# and requires you to use
GetPixel from the Win API?

Is this correct? Any other better ways of doing this?

Thanks,

Feb 21 '06 #3
Tim Wilson wrote:
Assuming that you're image is represented as a Bitmap type, you can use the
GetPixel method. So in your case, you can cast the Image property of the
PictureBox to a Bitmap and then call the GetPixel method, assuming that the
Image property is not null.
http://msdn.microsoft.com/library/de...pixeltopic.asp


Thats great thanks.

Feb 21 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

43 posts views Thread by Dom | last post: by
1 post views Thread by Hamster | last post: by
13 posts views Thread by Martijn Mulder | last post: by
3 posts views Thread by Johny | last post: by
4 posts views Thread by Johny | last post: by
5 posts views Thread by pepito72 | last post: by
4 posts views Thread by cjstuttle | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.