public void SetImage(string imagePath) { _bitmap = (Bitmap)Image.FromFile(imagePath); //resize to a base size so that it does not take too much time during test stripping var imageAlterationParams = new ImageAlterationParams { ResizeType = ResizeType.ResizeSufficiently }; _bitmap = MainProcessor.ResizeImage(_bitmap, imageAlterationParams); var imageBrush = new ImageBrush(new BitmapImage(new Uri(imagePath, UriKind.Absolute))); SampleImageCanvas.Background = imageBrush; }
public void TestWithExtraWidthThatMakesLeftNegative() { var imageFolder = string.Format(@"{0}\{1}", ExecutionDirInfoHelper.GetInputDirPath(), "testcropping_disc_very_left_of_image"); var clickInputs = MainProcessor.GetClickInputsFromFile(imageFolder + @"\ClickInputs.xml"); var imagePath = string.Format(@"{0}\{1}", imageFolder, clickInputs.ImageClickInputDetailsList[0].ImageName); _image = (Bitmap)Image.FromFile(imagePath); var imageAlterationParams = new ImageAlterationParams { MinImageHeightRatio = 0.7, PercentExtraWidth = 10, InvalidColor = _bkColor, BottomPaddingPercent = 0 }; var croppedImg = ImageCropper.GetCroppedImage(clickInputs.ImageClickInputDetailsList[0], _image, imageAlterationParams); var outputPath = string.Format(@"{0}\cropped_with_extra_beyond_left.jpg", _outputFolder); croppedImg.Save(outputPath); }