private void NegativeButton_Click(object sender, EventArgs e) { Bitmap originalImage = new Bitmap(imagePath); Bitmap negativeImage = ImageEditingProgram.MakeImageNegative(originalImage); editedImage.Image = negativeImage; currentImageSuffix = "_negative"; }
public void Test_IfNegativeImageReallyIsNegative() { Bitmap negativeTest = new Bitmap(3, 3); Color black = Color.FromArgb(255, 0, 0, 0); Color white = Color.FromArgb(255, 255, 255, 255); negativeTest.SetPixel(0, 0, black); negativeTest.SetPixel(0, 1, black); negativeTest.SetPixel(0, 2, black); negativeTest.SetPixel(1, 0, black); negativeTest.SetPixel(1, 1, black); negativeTest.SetPixel(1, 2, black); negativeTest.SetPixel(2, 0, black); negativeTest.SetPixel(2, 1, black); negativeTest.SetPixel(2, 2, black); Bitmap bitmapTestResult = ImageEditingProgram.MakeImageNegative(negativeTest); Assert.AreEqual(white, bitmapTestResult.GetPixel(0, 0)); Assert.AreEqual(white, bitmapTestResult.GetPixel(1, 1)); Assert.AreEqual(white, bitmapTestResult.GetPixel(2, 2)); }
static void Main(string[] args) { string imagePath; Bitmap originalImage; try { imagePath = args[0]; } catch (IndexOutOfRangeException) { Console.WriteLine("File path not entered, please enter a path to an image file"); imagePath = Console.ReadLine(); } bool validImageFile = FileHandler.CheckIfGivenFileExistsAndIsImage(imagePath); while (validImageFile == false) { if (FileHandler.CheckIfGivenFileExistsAndIsImage(imagePath) == false) { Console.WriteLine("Enter a valid file path to an image file"); imagePath = Console.ReadLine(); validImageFile = FileHandler.CheckIfGivenFileExistsAndIsImage(imagePath); } } originalImage = new Bitmap(imagePath); Bitmap greyScale = ImageEditingProgram.MakeImageGreyScale(originalImage); Bitmap negative = ImageEditingProgram.MakeImageNegative(originalImage); Bitmap blurred = ImageEditingProgram.MakeImageBlurred(originalImage); greyScale.Save(FileHandler.CreateCorrectFilenameForSaving(imagePath, "_greyScale")); negative.Save(FileHandler.CreateCorrectFilenameForSaving(imagePath, "_negative")); blurred.Save(FileHandler.CreateCorrectFilenameForSaving(imagePath, "_blurred")); }
public void Test_IfNegativeImageReturnsSameSize() { Bitmap negativeTest = new Bitmap(3, 3); Assert.AreEqual(negativeTest.Size, ImageEditingProgram.MakeImageNegative(negativeTest).Size); }