Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I have done a project in Visual C# Express 2010. When we move a mouse pointer on to the image and click on a image, the color under the mouse pointer would be displayed and R,G,B values can be displayed in a textbox.

But I am unable to do the same project in Silverlight Application i.e., WPF by Visual Web Developer 2010. Can anybody help me regarding this?

I can post the whole code to individual e-mail, if I get any response to this question.
Posted
Comments
Bruno Tagliapietra 22-Apr-11 10:04am    
try sending code in a zip file at bruno.tagliapietra@gmail.com

if you're sending a whole solution folder, "Clean" away the exe files from visual studio first.

You can use tooltip and bind the RGB values as tooltip text .
Can you tell which control is used for displaying the color ?
 
Share this answer
 
Comments
Member 7810323 26-Apr-11 19:56pm    
I have used the below code.

WriteableBitmap wb = new WriteableBitmap(image1, null);
double x = e.GetPosition(this).X;
double y = e.GetPosition(this).Y;
textBox1.Text = x.ToString();
textBox2.Text = y.ToString();

int col = wb.Pixels[(int)(y * image1.Width) + (int)x];
textBox3.Text = ((col >> 16) & 0xFF).ToString() + " " +
((col >> 8) & 0xFF).ToString() + " " +
((col >> 0) & 0xFF).ToString();

Can anybody please modify this code to get the color at a particular pixel from the image. and I should be able to display the RGB values of that color too.
This[^] might be possible using the WriteableBitmap class.
 
Share this answer
 
Comments
Member 7810323 26-Apr-11 19:56pm    
I have used the below code.

WriteableBitmap wb = new WriteableBitmap(image1, null);
double x = e.GetPosition(this).X;
double y = e.GetPosition(this).Y;
textBox1.Text = x.ToString();
textBox2.Text = y.ToString();

int col = wb.Pixels[(int)(y * image1.Width) + (int)x];
textBox3.Text = ((col >> 16) & 0xFF).ToString() + " " +
((col >> 8) & 0xFF).ToString() + " " +
((col >> 0) & 0xFF).ToString();

Can anybody please modify this code to get the color at a particular pixel from the image. and I should be able to display the RGB values of that color too.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900