实例介绍
【实例简介】
【实例截图】
【核心代码】
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace CSharpFilters
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Drawing.Bitmap m_Bitmap;
private System.Drawing.Bitmap m_Undo;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem FileLoad;
private System.Windows.Forms.MenuItem FileSave;
private System.Windows.Forms.MenuItem FileExit;
private System.Windows.Forms.MenuItem FilterInvert;
private System.Windows.Forms.MenuItem FilterGrayScale;
private System.Windows.Forms.MenuItem FilterBrightness;
private System.Windows.Forms.MenuItem FilterContrast;
private System.Windows.Forms.MenuItem FilterGamma;
private System.Windows.Forms.MenuItem FilterColor;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem Zoom25;
private double Zoom = 1.0;
private System.Windows.Forms.MenuItem Zoom50;
private System.Windows.Forms.MenuItem Zoom100;
private System.Windows.Forms.MenuItem Zoom150;
private System.Windows.Forms.MenuItem Zoom200;
private System.Windows.Forms.MenuItem Zoom300;
private System.Windows.Forms.MenuItem Zoom500;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem FilterSmooth;
private System.Windows.Forms.MenuItem GaussianBlur;
private System.Windows.Forms.MenuItem MeanRemoval;
private System.Windows.Forms.MenuItem Sharpen;
private System.Windows.Forms.MenuItem EmbossLaplacian;
private System.Windows.Forms.MenuItem EdgeDetectQuick;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem Undo;
private System.Windows.Forms.MenuItem FilterCustom;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.MenuItem EdgeKirsh;
private System.Windows.Forms.MenuItem EdgePrewitt;
private System.Windows.Forms.MenuItem EdgeSobell;
private System.Windows.Forms.MenuItem EdgeDetectHorizontal;
private System.Windows.Forms.MenuItem EdgeVertical;
private System.Windows.Forms.MenuItem EdgeHomogenity;
private System.Windows.Forms.MenuItem EdgeDifference;
private System.Windows.Forms.MenuItem EdgeEnhance;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
m_Bitmap= new Bitmap(2, 2);
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.FileLoad = new System.Windows.Forms.MenuItem();
this.FileSave = new System.Windows.Forms.MenuItem();
this.FileExit = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.Undo = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.FilterInvert = new System.Windows.Forms.MenuItem();
this.FilterGrayScale = new System.Windows.Forms.MenuItem();
this.FilterBrightness = new System.Windows.Forms.MenuItem();
this.FilterContrast = new System.Windows.Forms.MenuItem();
this.FilterGamma = new System.Windows.Forms.MenuItem();
this.FilterColor = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.FilterSmooth = new System.Windows.Forms.MenuItem();
this.GaussianBlur = new System.Windows.Forms.MenuItem();
this.MeanRemoval = new System.Windows.Forms.MenuItem();
this.Sharpen = new System.Windows.Forms.MenuItem();
this.EmbossLaplacian = new System.Windows.Forms.MenuItem();
this.EdgeDetectQuick = new System.Windows.Forms.MenuItem();
this.FilterCustom = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.EdgeKirsh = new System.Windows.Forms.MenuItem();
this.EdgePrewitt = new System.Windows.Forms.MenuItem();
this.EdgeSobell = new System.Windows.Forms.MenuItem();
this.EdgeDetectHorizontal = new System.Windows.Forms.MenuItem();
this.EdgeVertical = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.Zoom25 = new System.Windows.Forms.MenuItem();
this.Zoom50 = new System.Windows.Forms.MenuItem();
this.Zoom100 = new System.Windows.Forms.MenuItem();
this.Zoom150 = new System.Windows.Forms.MenuItem();
this.Zoom200 = new System.Windows.Forms.MenuItem();
this.Zoom300 = new System.Windows.Forms.MenuItem();
this.Zoom500 = new System.Windows.Forms.MenuItem();
this.EdgeHomogenity = new System.Windows.Forms.MenuItem();
this.EdgeDifference = new System.Windows.Forms.MenuItem();
this.EdgeEnhance = new System.Windows.Forms.MenuItem();
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem5,
this.menuItem4,
this.menuItem3,
this.menuItem6,
this.menuItem2});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.FileLoad,
this.FileSave,
this.FileExit});
this.menuItem1.Text = "File";
//
// FileLoad
//
this.FileLoad.Index = 0;
this.FileLoad.Shortcut = System.Windows.Forms.Shortcut.CtrlL;
this.FileLoad.Text = "Load";
this.FileLoad.Click = new System.EventHandler(this.File_Load);
//
// FileSave
//
this.FileSave.Index = 1;
this.FileSave.Shortcut = System.Windows.Forms.Shortcut.CtrlS;
this.FileSave.Text = "Save";
this.FileSave.Click = new System.EventHandler(this.File_Save);
//
// FileExit
//
this.FileExit.Index = 2;
this.FileExit.Text = "Exit";
this.FileExit.Click = new System.EventHandler(this.File_Exit);
//
// menuItem5
//
this.menuItem5.Index = 1;
this.menuItem5.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.Undo});
this.menuItem5.Text = "Edit";
//
// Undo
//
this.Undo.Index = 0;
this.Undo.Text = "Undo";
this.Undo.Click = new System.EventHandler(this.OnUndo);
//
// menuItem4
//
this.menuItem4.Index = 2;
this.menuItem4.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.FilterInvert,
this.FilterGrayScale,
this.FilterBrightness,
this.FilterContrast,
this.FilterGamma,
this.FilterColor});
this.menuItem4.Text = "Filter";
//
// FilterInvert
//
this.FilterInvert.Index = 0;
this.FilterInvert.Text = "Invert";
this.FilterInvert.Click = new System.EventHandler(this.Filter_Invert);
//
// FilterGrayScale
//
this.FilterGrayScale.Index = 1;
this.FilterGrayScale.Text = "GrayScale";
this.FilterGrayScale.Click = new System.EventHandler(this.Filter_GrayScale);
//
// FilterBrightness
//
this.FilterBrightness.Index = 2;
this.FilterBrightness.Text = "Brightness";
this.FilterBrightness.Click = new System.EventHandler(this.Filter_Brightness);
//
// FilterContrast
//
this.FilterContrast.Index = 3;
this.FilterContrast.Text = "Contrast";
this.FilterContrast.Click = new System.EventHandler(this.Filter_Contrast);
//
// FilterGamma
//
this.FilterGamma.Index = 4;
this.FilterGamma.Text = "Gamma";
this.FilterGamma.Click = new System.EventHandler(this.Filter_Gamma);
//
// FilterColor
//
this.FilterColor.Index = 5;
this.FilterColor.Text = "Color";
this.FilterColor.Click = new System.EventHandler(this.Filter_Color);
//
// menuItem3
//
this.menuItem3.Index = 3;
this.menuItem3.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.FilterSmooth,
this.GaussianBlur,
this.MeanRemoval,
this.Sharpen,
this.EmbossLaplacian,
this.EdgeDetectQuick,
this.FilterCustom});
this.menuItem3.Text = "Convolution";
//
// FilterSmooth
//
this.FilterSmooth.Index = 0;
this.FilterSmooth.Text = "Smooth";
this.FilterSmooth.Click = new System.EventHandler(this.OnFilterSmooth);
//
// GaussianBlur
//
this.GaussianBlur.Index = 1;
this.GaussianBlur.Text = "Gaussian Blur";
this.GaussianBlur.Click = new System.EventHandler(this.OnGaussianBlur);
//
// MeanRemoval
//
this.MeanRemoval.Index = 2;
this.MeanRemoval.Text = "Mean Removal";
this.MeanRemoval.Click = new System.EventHandler(this.OnMeanRemoval);
//
// Sharpen
//
this.Sharpen.Index = 3;
this.Sharpen.Text = "Sharpen";
this.Sharpen.Click = new System.EventHandler(this.OnSharpen);
//
// EmbossLaplacian
//
this.EmbossLaplacian.Index = 4;
this.EmbossLaplacian.Text = "EmbossLaplacian";
this.EmbossLaplacian.Click = new System.EventHandler(this.OnEmbossLaplacian);
//
// EdgeDetectQuick
//
this.EdgeDetectQuick.Index = 5;
this.EdgeDetectQuick.Text = "EdgeDetectQuick";
this.EdgeDetectQuick.Click = new System.EventHandler(this.OnEdgeDetectQuick);
//
// FilterCustom
//
this.FilterCustom.Index = 6;
this.FilterCustom.Text = "Custom";
this.FilterCustom.Click = new System.EventHandler(this.OnFilterCustom);
//
// menuItem6
//
this.menuItem6.Index = 4;
this.menuItem6.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.EdgeKirsh,
this.EdgePrewitt,
this.EdgeSobell,
this.EdgeDetectHorizontal,
this.EdgeVertical,
this.EdgeHomogenity,
this.EdgeDifference,
this.EdgeEnhance});
this.menuItem6.Text = "Edge Detection";
//
// EdgeKirsh
//
this.EdgeKirsh.Index = 0;
this.EdgeKirsh.Text = "Kirsh";
this.EdgeKirsh.Click = new System.EventHandler(this.OnEdgeKirsh);
//
// EdgePrewitt
//
this.EdgePrewitt.Index = 1;
this.EdgePrewitt.Text = "Prewitt";
this.EdgePrewitt.Click = new System.EventHandler(this.OnEdgePrewitt);
//
// EdgeSobell
//
this.EdgeSobell.Index = 2;
this.EdgeSobell.Text = "Sobel";
this.EdgeSobell.Click = new System.EventHandler(this.OnEdgeSobell);
//
// EdgeDetectHorizontal
//
this.EdgeDetectHorizontal.Index = 3;
this.EdgeDetectHorizontal.Text = "Horizontal";
this.EdgeDetectHorizontal.Click = new System.EventHandler(this.OnEdgeHorizontal);
//
// EdgeVertical
//
this.EdgeVertical.Index = 4;
this.EdgeVertical.Text = "Vertical";
this.EdgeVertical.Click = new System.EventHandler(this.OnEdgeVertical);
//
// menuItem2
//
this.menuItem2.Index = 5;
this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.Zoom25,
this.Zoom50,
this.Zoom100,
this.Zoom150,
this.Zoom200,
this.Zoom300,
this.Zoom500});
this.menuItem2.Text = "Zoom";
//
// Zoom25
//
this.Zoom25.Index = 0;
this.Zoom25.Text = "25%";
this.Zoom25.Click = new System.EventHandler(this.OnZoom25);
//
// Zoom50
//
this.Zoom50.Index = 1;
this.Zoom50.Text = "50%";
this.Zoom50.Click = new System.EventHandler(this.OnZoom50);
//
// Zoom100
//
this.Zoom100.Index = 2;
this.Zoom100.Text = "100%";
this.Zoom100.Click = new System.EventHandler(this.OnZoom100);
//
// Zoom150
//
this.Zoom150.Index = 3;
this.Zoom150.Text = "150%";
this.Zoom150.Click = new System.EventHandler(this.OnZoom150);
//
// Zoom200
//
this.Zoom200.Index = 4;
this.Zoom200.Text = "200%";
this.Zoom200.Click = new System.EventHandler(this.OnZoom200);
//
// Zoom300
//
this.Zoom300.Index = 5;
this.Zoom300.Text = "300%";
this.Zoom300.Click = new System.EventHandler(this.OnZoom300);
//
// Zoom500
//
this.Zoom500.Index = 6;
this.Zoom500.Text = "500%";
this.Zoom500.Click = new System.EventHandler(this.OnZoom500);
//
// EdgeHomogenity
//
this.EdgeHomogenity.Index = 5;
this.EdgeHomogenity.Text = "Homogenity";
this.EdgeHomogenity.Click = new System.EventHandler(this.OnEdgeHomogenity);
//
// EdgeDifference
//
this.EdgeDifference.Index = 6;
this.EdgeDifference.Text = "Difference";
this.EdgeDifference.Click = new System.EventHandler(this.OnEdgeDifference);
//
// EdgeEnhance
//
this.EdgeEnhance.Index = 7;
this.EdgeEnhance.Text = "Edge Enhance";
this.EdgeEnhance.Click = new System.EventHandler(this.EdgeEnhance_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.ClientSize = new System.Drawing.Size(488, 421);
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.Text = "Graphic Filters For Dummies";
this.Load = new System.EventHandler(this.Form1_Load);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
protected override void OnPaint (PaintEventArgs e)
{
Graphics g = e.Graphics;
g.DrawImage(m_Bitmap, new Rectangle(this.AutoScrollPosition.X, this.AutoScrollPosition.Y, (int)(m_Bitmap.Width*Zoom), (int)(m_Bitmap.Height * Zoom)));
}
private void Form1_Load(object sender, System.EventArgs e)
{
}
private void File_Load(object sender, System.EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.InitialDirectory = "c:\\" ;
openFileDialog.Filter = "Bitmap files (*.bmp)|*.bmp|Jpeg files (*.jpg)|*.jpg|All valid files (*.bmp/*.jpg)|*.bmp/*.jpg";
openFileDialog.FilterIndex = 2 ;
openFileDialog.RestoreDirectory = true ;
if(DialogResult.OK == openFileDialog.ShowDialog())
{
m_Bitmap = (Bitmap)Bitmap.FromFile(openFileDialog.FileName, false);
this.AutoScroll = true;
this.AutoScrollMinSize = new Size ((int)(m_Bitmap.Width * Zoom), (int)(m_Bitmap.Height * Zoom));
this.Invalidate();
}
}
private void File_Save(object sender, System.EventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.InitialDirectory = "c:\\" ;
saveFileDialog.Filter = "Bitmap files (*.bmp)|*.bmp|Jpeg files (*.jpg)|*.jpg|All valid files (*.bmp/*.jpg)|*.bmp/*.jpg" ;
saveFileDialog.FilterIndex = 1 ;
saveFileDialog.RestoreDirectory = true ;
if(DialogResult.OK == saveFileDialog.ShowDialog())
{
m_Bitmap.Save(saveFileDialog.FileName);
}
}
private void File_Exit(object sender, System.EventArgs e)
{
this.Close();
}
private void Filter_Invert(object sender, System.EventArgs e)
{
m_Undo = (Bitmap)m_Bitmap.Clone();
if(BitmapFilter.Invert(m_Bitmap))
this.Invalidate();
}
private void Filter_GrayScale(object sender, System.EventArgs e)
{
m_Undo = (Bitmap)m_Bitmap.Clone();
if(BitmapFilter.GrayScale(m_Bitmap))
this.Invalidate();
}
private void Filter_Brightness(object sender, System.EventArgs e)
{
Parameter dlg = new Parameter();
dlg.nValue = 0;
if (DialogResult.OK == dlg.ShowDialog())
{
m_Undo = (Bitmap)m_Bitmap.Clone();
if(BitmapFilter.Brightness(m_Bitmap, dlg.nValue))
this.Invalidate();
}
}
private void Filter_Contrast(object sender, System.EventArgs e)
{
Parameter dlg = new Parameter();
dlg.nValue = 0;
if (DialogResult.OK == dlg.ShowDialog())
{
m_Undo = (Bitmap)m_Bitmap.Clone();
if(BitmapFilter.Contrast(m_Bitmap, (sbyte)dlg.nValue))
this.Invalidate();
}
}
private void Filter_Gamma(object sender, System.EventArgs e)
{
GammaInput dlg = new GammaInput();
dlg.red = dlg.green = dlg.blue = 1;
if (DialogResult.OK == dlg.ShowDialog())
{
m_Undo = (Bitmap)m_Bitmap.Clone();
if(BitmapFilter.Gamma(m_Bitmap, dlg.red, dlg.green, dlg.blue))
this.Invalidate();
}
}
private void Filter_Color(object sender, System.EventArgs e)
{
ColorInput dlg = new ColorInput();
dlg.red = dlg.green = dlg.blue = 0;
if (DialogResult.OK == dlg.ShowDialog())
{
m_Undo = (Bitmap)m_Bitmap.Clone();
if(BitmapFilter.Color(m_Bitmap, dlg.red, dlg.green, dlg.blue))
this.Invalidate();
}
}
private void OnZoom25(object sender, System.EventArgs e)
{
Zoom = .25;
this.AutoScrollMinSize = new Size ((int)(m_Bitmap.Width * Zoom), (int)(m_Bitmap.Height * Zoom));
this.Invalidate();
}
private void OnZoom50(object sender, System.EventArgs e)
{
Zoom = .5;
this.AutoScrollMinSize = new Size ((int)(m_Bitmap.Width * Zoom), (int)(m_Bitmap.Height * Zoom));
this.Invalidate();
}
private void OnZoom100(object sender, System.EventArgs e)
{
Zoom = 1.0;
this.AutoScrollMinSize = new Size ((int)(m_Bitmap.Width * Zoom), (int)(m_Bitmap.Height * Zoom));
this.Invalidate();
}
private void OnZoom150(object sender, System.EventArgs e)
{
Zoom = 1.5;
this.AutoScrollMinSize = new Size ((int)(m_Bitmap.Width * Zoom), (int)(m_Bitmap.Height * Zoom));
this.Invalidate();
}
private void OnZoom200(object sender, System.EventArgs e)
{
Zoom = 2.0;
this.AutoScrollMinSize = new Size ((int)(m_Bitmap.Width * Zoom), (int)(m_Bitmap.Height * Zoom));
this.Invalidate();
}
private void OnZoom300(object sender, System.EventArgs e)
{
Zoom = 3.0;
this.AutoScrollMinSize = new Size ((int)(m_Bitmap.Width * Zoom), (int)(m_Bitmap.Height * Zoom));
this.Invalidate();
}
private void OnZoom500(object sender, System.EventArgs e)
{
Zoom = 5;
this.AutoScrollMinSize = new Size ((int)(m_Bitmap.Width * Zoom), (int)(m_Bitmap.Height * Zoom));
this.Invalidate();
}
private void OnFilterSmooth(object sender, System.EventArgs e)
{
m_Undo = (Bitmap)m_Bitmap.Clone();
if(BitmapFilter.Smooth(m_Bitmap, 1))
this.Invalidate();
}
private void OnGaussianBlur(object sender, System.EventArgs e)
{
m_Undo = (Bitmap)m_Bitmap.Clone();
if(BitmapFilter.GaussianBlur(m_Bitmap, 4))
this.Invalidate();
}
private void OnMeanRemoval(object sender, System.EventArgs e)
{
m_Undo = (Bitmap)m_Bitmap.Clone();
if(BitmapFilter.MeanRemoval(m_Bitmap, 9))
this.Invalidate();
}
private void OnSharpen(object sender, System.EventArgs e)
{
m_Undo = (Bitmap)m_Bitmap.Clone();
if(BitmapFilter.Sharpen(m_Bitmap, 11))
this.Invalidate();
}
private void OnEmbossLaplacian(object sender, System.EventArgs e)
{
m_Undo = (Bitmap)m_Bitmap.Clone();
if(BitmapFilter.EmbossLaplacian(m_Bitmap))
this.Invalidate();
}
private void OnEdgeDetectQuick(object sender, System.EventArgs e)
{
m_Undo = (Bitmap)m_Bitmap.Clone();
if(BitmapFilter.EdgeDetectQuick(m_Bitmap))
this.Invalidate();
}
private void OnUndo(object sender, System.EventArgs e)
{
Bitmap temp = (Bitmap)m_Bitmap.Clone();
m_Bitmap = (Bitmap)m_Undo.Clone();
m_Undo = (Bitmap)temp.Clone();
this.Invalidate();
}
private void OnFilterCustom(object sender, System.EventArgs e)
{
Convolution dlg = new Convolution();
if (DialogResult.OK == dlg.ShowDialog())
{
m_Undo = (Bitmap)m_Bitmap.Clone();
if(BitmapFilter.Conv3x3(m_Bitmap, dlg.Matrix))
this.Invalidate();
}
}
private void OnEdgeKirsh(object sender, System.EventArgs e)
{
Parameter dlg = new Parameter();
dlg.nValue = 0;
if (DialogResult.OK == dlg.ShowDialog())
{
m_Undo = (Bitmap)m_Bitmap.Clone();
if(BitmapFilter.EdgeDetectConvolution(m_Bitmap, BitmapFilter.EDGE_DETECT_KIRSH, (byte)dlg.nValue))
this.Invalidate();
}
}
private void OnEdgePrewitt(object sender, System.EventArgs e)
{
Parameter dlg = new Parameter();
dlg.nValue = 0;
if (DialogResult.OK == dlg.ShowDialog())
{
m_Undo = (Bitmap)m_Bitmap.Clone();
if(BitmapFilter.EdgeDetectConvolution(m_Bitmap, BitmapFilter.EDGE_DETECT_PREWITT, (byte)dlg.nValue))
this.Invalidate();
}
}
private void OnEdgeSobell(object sender, System.EventArgs e)
{
Parameter dlg = new Parameter();
dlg.nValue = 0;
if (DialogResult.OK == dlg.ShowDialog())
{
m_Undo = (Bitmap)m_Bitmap.Clone();
if(BitmapFilter.EdgeDetectConvolution(m_Bitmap, BitmapFilter.EDGE_DETECT_SOBEL, (byte)dlg.nValue))
this.Invalidate();
}
}
private void OnEdgeHorizontal(object sender, System.EventArgs e)
{
m_Undo = (Bitmap)m_Bitmap.Clone();
if(BitmapFilter.EdgeDetectHorizontal(m_Bitmap))
this.Invalidate();
}
private void OnEdgeVertical(object sender, System.EventArgs e)
{
m_Undo = (Bitmap)m_Bitmap.Clone();
if(BitmapFilter.EdgeDetectVertical(m_Bitmap))
this.Invalidate();
}
private void OnEdgeHomogenity(object sender, System.EventArgs e)
{
Parameter dlg = new Parameter();
dlg.nValue = 0;
if (DialogResult.OK == dlg.ShowDialog())
{
m_Undo = (Bitmap)m_Bitmap.Clone();
if(BitmapFilter.EdgeDetectHomogenity(m_Bitmap, (byte)dlg.nValue))
this.Invalidate();
}
}
private void OnEdgeDifference(object sender, System.EventArgs e)
{
Parameter dlg = new Parameter();
dlg.nValue = 0;
if (DialogResult.OK == dlg.ShowDialog())
{
m_Undo = (Bitmap)m_Bitmap.Clone();
if(BitmapFilter.EdgeDetectDifference(m_Bitmap, (byte)dlg.nValue))
this.Invalidate();
}
}
private void EdgeEnhance_Click(object sender, System.EventArgs e)
{
Parameter dlg = new Parameter();
dlg.nValue = 0;
if (DialogResult.OK == dlg.ShowDialog())
{
m_Undo = (Bitmap)m_Bitmap.Clone();
if(BitmapFilter.EdgeEnhance(m_Bitmap, (byte)dlg.nValue))
this.Invalidate();
}
}
}
}
好例子网口号:伸出你的我的手 — 分享!
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明


网友评论
我要评论