操作顺序:
首先加载要调整亮度的图像。
然后通过循环遍历图像的像素,并根据需要增加像素的亮度值。
最后,将调整后的图像保存回原始文件。
代码如下:
using System;
using System.Drawing.Imaging;
class Program
{
static void Main()
{
// 替换为实际的图像文件路径
string filePath = @"path\to\your\image.jpg";
AdjustBrightness(filePath);
}
static void AdjustBrightness(string filePath)
{
Bitmap bitmap = new Bitmap(filePath);
for (int x = 0; x < bitmap.Width; x++)
{
for (int y = 0; y < bitmap.Height; y++)
{
Color color = bitmap.GetPixel(x, y);
int red = color.R;
int green = color.G;
int blue = color.B;
// 根据需要调整亮度
red += 10;
green += 10;
blue += 10;
color = Color.FromArgb(red, green, blue);
bitmap.SetPixel(x, y, color);
}
}
bitmap.Save(filePath);
}
}