static void Main(string[] args) { FileHandler importImage = new FileHandler(); Bitmap image = null; ImageConverter imageConverter = new ImageConverter(); string filePath = null; if (args.Length == 0) { Console.WriteLine("Select an image to convert"); filePath = Console.ReadLine(); } else { filePath = args[0]; } try { if (importImage.TryIfFilePathIsAnImage(filePath)) { image = new Bitmap(filePath); } else { Console.WriteLine("Wrong input"); Environment.Exit(0); } } catch (FileNotFoundException) { Console.WriteLine("File dont exist, try again"); } catch (ArgumentException) { Console.WriteLine("Wrong input"); Environment.Exit(0); } Bitmap negativeImage = imageConverter.ConvertToNegative(image); var negativeFileName = importImage.AddSuffixToFile(filePath, "Negative"); negativeImage.Save(negativeFileName); negativeImage.Dispose(); var blackWhiteImage = imageConverter.ConvertToBlackAndWhite(image); var blackAndWhiteFileName = importImage.AddSuffixToFile(filePath, "BlackAndWhite"); blackWhiteImage.Save(blackAndWhiteFileName); blackWhiteImage.Dispose(); var blurredImage = imageConverter.ConvertToBlurred(image); var blurredFileName = importImage.AddSuffixToFile(filePath, "Blurred"); blurredImage.Save(blurredFileName); blurredImage.Dispose(); image.Dispose(); }
public void TestAddSuffixToFile() { string expectedResult = @"C:\Users\91danand\Desktop\äpplen\äpplen_Negative.jpg"; string result = fileHandler.AddSuffixToFile(@"C:\Users\91danand\Desktop\äpplen\äpplen.jpg", "Negative"); Assert.AreEqual(expectedResult, result); }
private void Button3_Click(object sender, EventArgs e) { ImageClassLibrary.ImageConverter imageConverter = new ImageClassLibrary.ImageConverter(); FileHandler importImg = new FileHandler(); pictureBox1.Image = imageConverter.ConvertToBlurred((Bitmap)pictureBox2.Image); pictureBox1.Name = importImg.AddSuffixToFile(openFileDialog1.FileName, "blurred"); }