Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello,i want a code which retrieve the color from an image.where image is in fix format and x-y co-ordinate also...i want a read pixel and find the color of that pixel not by mouse positioning by only co-ordinates.plzzzzzzzzz Confused | :confused:
Posted
Updated 5-Oct-13 7:26am
v2
Comments
BillWoodruff 5-Oct-13 13:27pm    
Please do not post the same question on more than one forum.

1 solution

You may try something like below.

private void GetPixel_Example(PaintEventArgs e)
{

    // Create a Bitmap object from an image file.
    Bitmap myBitmap = new Bitmap("Grapes.jpg");

    // Get the color of a pixel within myBitmap.
    Color pixelColor = myBitmap.GetPixel(50, 50);

    // Fill a rectangle with pixelColor.
    SolidBrush pixelBrush = new SolidBrush(pixelColor);
    e.Graphics.FillRectangle(pixelBrush, 0, 0, 100, 100);
}


For more info:

Bitmap.GetPixel Method

Pixel Coordinates

I hope this will help to you.
 
Share this answer
 
v2

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