private void filtergray_Click(object sender, EventArgs e) {//Grayscale Pictures Colors if (BitmapFilter.GrayScale(image)) { this.Invalidate(); } }
private void grayScaleToolStripMenuItem_Click(object sender, EventArgs e) { Bitmap currentBitmap = (Bitmap)drawingCanvas.Contents; if (BitmapFilter.GrayScale(currentBitmap)) { drawingCanvas.Contents = currentBitmap; this.Invalidate(); } }
private void button1_Click(object sender, EventArgs e) { BitmapFilter.Contrast(pirst, 100); progressBar1.Value += 2; BitmapFilter.GaussianBlur(pirst, 10); progressBar1.Value += 3; BitmapFilter.GrayScale(pirst); progressBar1.Value += 2; BitmapFilter.Threshold(ref pirst, ref sekond, 235); progressBar1.Value += 15; read(); label1.Text = "Done"; pictureBox2.Image = sekond; show(); }
/// <summary> /// 指定した画像にフィルタをかける /// </summary> /// <param name="image"></param> private bool _SetFilter(Bitmap image) { if (image == null) { throw new ArgumentNullException("image"); } switch (filter) { case ImageFilter.Alpha: return(BitmapFilter.Brightness(image, 100)); case ImageFilter.Mosaic: return(BitmapFilter.Pixelate(image, 3, false)); case ImageFilter.GrayScale: return(BitmapFilter.GrayScale(image)); default: return(false); } }
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); }; }