0
我正在創建一個非常基本的圖像編輯器,並嘗試以數值方式設置顏色(R,G,B)的值。例如,這裏是我的代碼的一個片段:更改論壇應用程序中像素的顏色C#
for (int row = 0; row < thePicture.Width; row = row + 1)
{
for (int col = 0; col < thePicture.Height; col = col + 1)
{
Color pixel = thePicture.GetPixel(row, col);
pixel = Color.FromArgb(5 + pixel.R, 5 + pixel.G, 5 + pixel.B);
//+5 is making the image darker... I think
if (pixel.R > 255)//This is used to prevent the program from crashing
{
pixel.R = //is this possible? or another way? I am intending
} //Make this 255
thePicture.SetPixel(row, col, pixel);
}
}
請注意,它是在Windows論壇。 請高人指點,對C#很基本瞭解。謝謝
非常有幫助!謝謝 – user2970816