473,394 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 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 2871
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

43
by: Dom | last post by:
can someone please help me display text in the console cout << "Testing"; in a different colour to the default one
4
by: Dj Frenzy | last post by:
Hi, I know how to use javascript to change a background image to another background image, and how to change a background colour to another background colour. Is there a way to change an image to a...
1
by: Hamster | last post by:
How can I draw 1x1 pixel dot?
13
by: Martijn Mulder | last post by:
I try to define a line with the length of 1 unit (1 pixel) that is, in fact, just a point on the screen. But when I draw it with a wide pen with the appropriate StartCap and EndCap (Round), it will...
3
by: Johny | last post by:
I use PIL to write some text to a picture.The text must be seen wery clearly. I write the text to different pictures but to the same position. As pictures maybe different, colour, in the...
4
by: Johny | last post by:
I use PIL to write some text to a picture.The text must be seen wery clearly. I write the text to different pictures but to the same position. As pictures maybe different, colour, in the...
6
Robbie
by: Robbie | last post by:
Hi. I've made 2 functions which play around with colours. They convert a 'colour number' (I don't know what the proper name for it is, so I call it this - the Long given back by RGB(),...
5
by: pepito72 | last post by:
Hi A problem with trying to find the nearest colour. I have an image which I use GetPixel to return the colour of various points. However .... not all colours returned will be a...
4
by: cjstuttle | last post by:
Could anyone help me, I'm a python noob and need some help. im trying to find some code that will, given a screen co-ordinate, will give me the colour of that pixel in RGB. i have found a lot about...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.