private void filterinvert_Click(object sender, EventArgs e) {//Inverts Pictures Colors if (BitmapFilter.Invert(image)) { this.Invalidate(); } }
private void invertToolStripMenuItem_Click(object sender, EventArgs e) { Bitmap currentBitmap = (Bitmap)drawingCanvas.Contents; if (BitmapFilter.Invert(currentBitmap)) { drawingCanvas.Contents = currentBitmap; this.Invalidate(); } }
private void applyEffectButton_Click(object sender, EventArgs e) { uploadToSiteButton.Enabled = false; uploadToFtpButton.Enabled = false; applyEffectButton.Enabled = false; this.lifeTimer.Enabled = false; try { Bitmap p = (Bitmap)Bitmap.FromFile(_FileNameToHandle); Bitmap bpicture = new Bitmap(p); p.Dispose(); System.IO.File.Delete(_FileNameToHandle); switch (effectsComboBox.SelectedItem.ToString().ToLower()) { case "grayscale": if (BitmapFilter.GrayScale(bpicture)) { bpicture.Save(_FileNameToHandle); utilities.ShowMessage("image grayscaled", "apply effects"); } else { utilities.ShowMessage("unable to grayscale", "failed"); } break; case "invert": if (BitmapFilter.Invert(bpicture)) { bpicture.Save(_FileNameToHandle); utilities.ShowMessage("image inverted", "apply effects"); } else { utilities.ShowMessage("unable to invert", "failed"); } break; case "watermark": utilities.ShowMessage("not supported", "failed"); break; case "flip": utilities.ShowMessage("not supported", "failed"); break; case "brightness": if (BitmapFilter.Brightness(bpicture, 40)) { bpicture.Save(_FileNameToHandle); utilities.ShowMessage("image inverted", "apply effects"); } else { utilities.ShowMessage("unable to invert", "failed"); } break; default: break; } bpicture.Dispose(); } catch (Exception) { utilities.ShowMessage("unable to apply effect", "failed"); } this.applyEffectButton.Enabled = true; this.uploadToSiteButton.Enabled = true; this.uploadToFtpButton.Enabled = true; this.lifeTimer.Enabled = true; }
public FImageTest() { InitializeComponent(); Invert.OnGetImage += (value) => { var image = Properties.Resources.sample.Clone() as Bitmap; BitmapFilter.Invert(image); return(image); }; Gray.OnGetImage += (value) => { var image = Properties.Resources.sample.Clone() as Bitmap; BitmapFilter.GrayScale(image); return(image); }; Brightness.OnGetImage += (value) => { var bright = Properties.Resources.sample.Clone() as Bitmap; BitmapFilter.Brightness(bright, value); return(bright); }; Contrast.OnGetImage += (value) => { var c = Properties.Resources.sample.Clone() as Bitmap; BitmapFilter.Contrast(c, (sbyte)value); return(c); }; var g = Properties.Resources.sample.Clone() as Bitmap; BitmapFilter.Gamma(g, RTracBar.Value, GTracBar.Value, BTracBar.Value); GammaRLabel.Text = RTracBar.Value.ToString(); GammaGLabel.Text = GTracBar.Value.ToString(); GammaBLabel.Text = BTracBar.Value.ToString(); Pict5.Image = g; RTracBar.ValueChanged += (_s, _e) => { if (Pict5.Image != null) { Pict5.Image.Dispose(); } var g2 = Properties.Resources.sample.Clone() as Bitmap; BitmapFilter.Gamma(g2, RTracBar.Value, GTracBar.Value, BTracBar.Value); Pict5.Image = g2; GammaRLabel.Text = RTracBar.Value.ToString(); }; GTracBar.ValueChanged += (_s, _e) => { if (Pict5.Image != null) { Pict5.Image.Dispose(); } var g2 = Properties.Resources.sample.Clone() as Bitmap; BitmapFilter.Gamma(g2, RTracBar.Value, GTracBar.Value, BTracBar.Value); Pict5.Image = g2; GammaGLabel.Text = GTracBar.Value.ToString(); }; BTracBar.ValueChanged += (_s, _e) => { if (Pict5.Image != null) { Pict5.Image.Dispose(); } var g2 = Properties.Resources.sample.Clone() as Bitmap; BitmapFilter.Gamma(g2, RTracBar.Value, GTracBar.Value, BTracBar.Value); Pict5.Image = g2; GammaBLabel.Text = BTracBar.Value.ToString(); }; Smooth.OnGetImage += (value) => { var image = Properties.Resources.sample.Clone() as Bitmap; BitmapFilter.Smooth(image, value); return(image); }; Blur.OnGetImage += (value) => { var image = Properties.Resources.sample.Clone() as Bitmap; BitmapFilter.GaussianBlur(image, value); return(image); }; Removal.OnGetImage += (value) => { var image = Properties.Resources.sample.Clone() as Bitmap; BitmapFilter.MeanRemoval(image, value); return(image); }; Ave.OnGetImage += (value) => { var image = Properties.Resources.sample.Clone() as Bitmap; BitmapFilter.ave(image, value); return(image); }; Sharpen.OnGetImage += (value) => { var image = Properties.Resources.sample.Clone() as Bitmap; BitmapFilter.Sharpen(image, value); return(image); }; Emboss.OnGetImage += (value) => { var image = Properties.Resources.sample.Clone() as Bitmap; BitmapFilter.EmbossLaplacian(image); return(image); }; Edge.OnGetImage += (value) => { var image = Properties.Resources.sample.Clone() as Bitmap; BitmapFilter.EdgeDetectQuick(image); return(image); }; Median.OnGetImage += (value) => { var image = Properties.Resources.sample.Clone() as Bitmap; BitmapFilter.MedianFilter(image); return(image); }; Kuwahara.OnGetImage += (value) => { var image = Properties.Resources.sample.Clone() as Bitmap; BitmapFilter.Kuwahara(image, value); return(image); }; }