protected virtual void ApplyChanges() { if (OriginalImagePictureBox.Image == default) { return; } using (var imageBox = new ImageBox.ImageBox(OriginalImagePictureBox.Image).Statistics()) { ConfigurationGrayScaleCheckBox.Checked = !imageBox.Stats.IsGrayScale; OriginalImageBrightestPictureBox.BackColor = imageBox.Stats.Brightest; OriginalImageDarkestPictureBox.BackColor = imageBox.Stats.Darkest; // Gray Scale & Rotation & Flip imageBox.Color(!imageBox.Stats.IsGrayScale ? ColorerMatrix.GrayScale() : ColorerMatrix.Identity()) .Rotate((float)AngleNumericUpDown.Value, FillColorPictureBox.BackColor) .Flip(((FlipComboBoxItem)FlipComboBox.SelectedItem).Type) .Statistics(); ModifiedImageBrightestPictureBox.BackColor = imageBox.Stats.Brightest; ModifiedImageDarkestPictureBox.BackColor = imageBox.Stats.Darkest; if (PreviewImagePictureBox.Image != default) { var img = PreviewImagePictureBox.Image; PreviewImagePictureBox.Image = default; img.Dispose(); } if (PreviewImagePictureBox.Tag != default) { var img = PreviewImagePictureBox.Tag as Image; PreviewImagePictureBox.Image = default; img.Dispose(); } var image = new Bitmap(imageBox.Image.Width, imageBox.Image.Height); using (var g = Graphics.FromImage(image)) { g.DrawImage(imageBox.Image, 0, 0); } var tag = new Bitmap(imageBox.Image.Width, imageBox.Image.Height); using (var g = Graphics.FromImage(tag)) { g.DrawImage(imageBox.Image, 0, 0); } PreviewImagePictureBox.Tag = image; PreviewImagePictureBox.Image = tag; PreviewImagePictureBox.Visible = true; PreviewImageZoomValueChanged(this, EventArgs.Empty); } ApplySplitChanges(); }
protected virtual Image Modify(Image image, Request request) { var imageBox = new ImageBox.ImageBox(image).Statistics(); return(imageBox.Color(!imageBox.Stats.IsGrayScale ? ColorerMatrix.GrayScale() : ColorerMatrix.Identity()) .Rotate(request.Angle, request.Color) .Flip(request.FlipType).Image); }