以下是用两种实现取bmp图亮度的算法
1. public double GetBrightness(Bitmap bmp)
{
double brightness = 0;
Rectangle lightBox = new Rectangle(0, 0, bmp.Width,bmp.Height);
for (int x=lightBox.Left;x<lightBox.Right;x++)
{
for (int y = lightBox.Top; y < lightBox.Bottom; y++)
{
Color color = bmp.GetPixel(x, y);
brightness += color.G;
}
}
return brightness;
}
2. public double GetBrightness(Bitmap bmp)
{
double brightness = 0;
Rectangle lightBox = new Rectangle(0, 0, bmp.Width,bmp.Height);
try
{