Witam,
Napisałem program który zamienia pixel o danym kolorze na inny i chce nadpisać go jednak w momencie wywołania komendy Image.Save program mi się wywala z komunikatem "W interfejsie GDI+ wystąpił błąd rodzajowy.”
Kod:
static void Main(string[] args)
{
string appPath = Directory.GetCurrentDirectory();
string[] files = Directory.GetFiles(appPath, "*.png");
int i = 0;
Console.WriteLine("Start...");
foreach (var item in files)
{
Bitmap myBitmap = new Bitmap(item);
for (int Xcount = 0; Xcount < myBitmap.Width; Xcount++)
{
for (int Ycount = 0; Ycount < myBitmap.Height; Ycount++)
{
Color pixelColor = myBitmap.GetPixel(Xcount, Ycount);
if (pixelColor == Color.FromArgb(255, Color.Red)) myBitmap.SetPixel(Xcount, Ycount, Color.FromArgb(74, 65, 33));
}
}
string[] words = item.ToString().Split('\\');
string fileName = words[words.Length - 1];
myBitmap.Save(appPath + @"\" + fileName, ImageFormat.Png);
Console.WriteLine("Successful");
i++;
}
}