[已在C#论坛上重新发布消息]像素颜色由其坐标位置 [英] [Repost of message already on C# discussion forum] pixel color by its co-ordinates position

查看:62
本文介绍了[已在C#论坛上重新发布消息]像素颜色由其坐标位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我想要一个从图像中检索颜色的代码。其中图像是固定格式,xy坐标也是...我想要一个读取像素并找到该像素的颜色而不是仅通过鼠标定位co-ordinates.plzzzzzzzzz困惑| :confused:

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:

推荐答案

您可以尝试下面的内容。



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);
}





欲了解更多信息:



Bitmap.GetPixel方法



像素坐标



我希望这会对你有所帮助。



For more info:

Bitmap.GetPixel Method

Pixel Coordinates

I hope this will help to you.


这篇关于[已在C#论坛上重新发布消息]像素颜色由其坐标位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆