我需要像链接中一样在一张图像中交换两种颜色: 像这样:
此代码不正确 但我需要执行此操作的代码
private void Form1_Load(object sender, EventArgs e)
{
Bitmap bmp = new Bitmap(tsttPic.Image);
int width = bmp.Width;
int height = bmp.Height;
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
Color p = bmp.GetPixel(x, y);
int a = p.A;
int r = p.R;
int g = p.G;
int b = p.B;
if (r == 255 && b == 255 && b == 255)
{
r = 0;
g = 128;
b = 255;
}
else
{
r = 255;
g = 255;
b = 255;
}
bmp.SetPixel(x, y, Color.FromArgb(a, r, g, b));
}
}
neggPic.Image = bmp;
}