private void BlurredButton_Click(object sender, EventArgs e) { Bitmap originalImage = new Bitmap(imagePath); Bitmap blurredImage = ImageEditingProgram.MakeImageBlurred(originalImage); editedImage.Image = blurredImage; currentImageSuffix = "_blurred"; }
public void Test_CheckIfMiddlePixelsGetsExpectedBlur() { Bitmap blurredTest = new Bitmap(3, 3); Color black = Color.FromArgb(255, 0, 0, 0); Color white = Color.FromArgb(255, 255, 255, 255); Color expectedBlurredPixel = Color.FromArgb(255, 28, 28, 28); //3x3 with middle pixel white surrounded by black pixels blurredTest.SetPixel(0, 0, black); blurredTest.SetPixel(0, 1, black); blurredTest.SetPixel(0, 2, black); blurredTest.SetPixel(1, 0, black); blurredTest.SetPixel(1, 1, white); blurredTest.SetPixel(1, 2, black); blurredTest.SetPixel(2, 0, black); blurredTest.SetPixel(2, 1, black); blurredTest.SetPixel(2, 2, black); Assert.AreEqual(expectedBlurredPixel, ImageEditingProgram.MakeImageBlurred(blurredTest).GetPixel(1, 1)); }
public void Test_CheckIfSmallImageGetsCorrectBlur() { Bitmap blurredTest = new Bitmap(2, 2); Color black = Color.FromArgb(255, 0, 0, 0); Color white = Color.FromArgb(255, 255, 255, 255); Color expectedBlurredPixel = Color.FromArgb(255, 127, 127, 127); //2x2 with middle pixel white surrounded by black pixels blurredTest.SetPixel(0, 0, white); blurredTest.SetPixel(0, 1, black); blurredTest.SetPixel(1, 0, black); blurredTest.SetPixel(1, 1, white); Bitmap testResultBitmap = ImageEditingProgram.MakeImageBlurred(blurredTest); Assert.AreEqual(expectedBlurredPixel, testResultBitmap.GetPixel(0, 0)); Assert.AreEqual(expectedBlurredPixel, testResultBitmap.GetPixel(0, 1)); Assert.AreEqual(expectedBlurredPixel, testResultBitmap.GetPixel(1, 0)); Assert.AreEqual(expectedBlurredPixel, testResultBitmap.GetPixel(1, 1)); }
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_CheckIfBlurredImageReturnsSameSize() { Bitmap testBlurImageSize = new Bitmap(3, 3); Assert.AreEqual(testBlurImageSize.Size, ImageEditingProgram.MakeImageBlurred(testBlurImageSize).Size); }