Bitmap.GetPixel Method
以下是msdn中的例子
只要获得了color之后可以通过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); }
private string Color2String(Color clr)
{
return String.Format(@"{0},{1},{2}", clr.R, clr.G, clr.B);
}
{
return String.Format(@"{0},{1},{2}", clr.R, clr.G, clr.B);
}
从而得到图片中的三原色的数值

这篇博客详细介绍了如何利用C#中的Bitmap类的GetPixel方法,来获取图像中指定位置像素的颜色信息。
1146

被折叠的 条评论
为什么被折叠?



