I hope this helps.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Imaging;
namespace Test_Image1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string path = @"d:\tmp\16";
foreach (var f in Directory.GetFiles(path, "*.jpg"))
{
using (Bitmap b = Bitmap.FromFile(f) as Bitmap)
{
using (Bitmap b2 = this.ProcessBitmap(b))
{
b2.Save(Path.Combine(path, "pp_" + Path.GetFileName(f)), ImageFormat.Jpeg);
}
}
}
foreach (var f in Directory.GetFiles(path, "pp_*.jpg"))
{
string fn = f.Replace("pp_", "");
File.Delete(fn);
File.Move(f, fn);
}
}
private Bitmap ProcessBitmap(Bitmap b)
{
Bitmap b2 = new Bitmap(b);
for (int i = 0; i < b2.Width; i++)
{
for (int j = 0; j < b2.Height; j++)
{
Color c = b2.GetPixel(i, j);
b2.SetPixel(i, j, Color.FromArgb(c.A, 255 - c.R, 255 - c.G, 255 - c.B));
}
}
return b2;
}
}
}