資源簡介
C#數字圖像處理3種典型方法:提取像素法、內存法、指針法。源代碼

代碼片段和文件信息
/*
?*?Copyright?2013?http://blog.csdn.net/fox666?https://code.csdn.net/fox666
?*?
?*?Licensed?under?the?Apache?License?Version?2.0?(the?“License“);
?*?you?may?not?use?this?file?except?in?compliance?with?the?License.
?*?You?may?obtain?a?copy?of?the?License?at
?*?
?*??????http://www.apache.org/licenses/LICENSE-2.0
?*?
?*?Unless?required?by?applicable?law?or?agreed?to?in?writing?software
?*?distributed?under?the?License?is?distributed?on?an?“AS?IS“?BASIS
?*?WITHOUT?WARRANTIES?OR?CONDITIONS?OF?ANY?KIND?either?express?or?implied.
?*?See?the?License?for?the?specific?language?governing?permissions?and
?*?limitations?under?the?License.
?*/
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
namespace?第二章
{
????public?partial?class?Form1?:?Form
????{
????????private?string?curFileName;
????????private?System.Drawing.Bitmap?curBitmap;
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?open_Click(object?sender?EventArgs?e)
????????{
????????????//創建OpenFileDialog
????????????OpenFileDialog?opnDlg?=?new?OpenFileDialog();
????????????opnDlg.Filter?=?“所有圖像文件|*.bmp;*.pcx;*.png;*.jpg;*.gif;“?+
????????????????“*.tif;*.ico;*.dxf;*.cgm;*.cdr;*.wmf;*.eps;*.emf|“?+
??????????????????“位圖(*.bmp;*.jpg;*.png;...)|*.bmp;*.pcx;*.png;*.jpg;*.gif;*.tif;*.ico|“?+
???????????????????“矢量圖(*.wmf;*.eps;*.emf:...)|*.dxf;*.cgm;*.cdr;*.wmf;*.eps;*.emf“;
????????????//設置對話框標題
????????????opnDlg.title?=?“打開圖像文件“;
????????????//啟用幫助按鈕
????????????opnDlg.ShowHelp?=?true;
????????????//如果結果為打開選定文件
????????????if?(opnDlg.ShowDialog()==DialogResult.OK?)
????????????{
????????????????//讀取當前選中文件名
????????????????curFileName?=?opnDlg.FileName;
????????????????//使用Image.
????????????????try?
????????????????{
????????????????????curBitmap?=?(Bitmap)Image.FromFile(curFileName);
????????????????}
????????????????catch?(?Exception?exp)
????????????????{
????????????????????//拋出異常
????????????????????MessageBox.Show(exp.Message);
????????????????}
????????????????//對窗體重新繪制
????????????????Invalidate();
????????????}
????????}
????????private?void?save_Click(object?sender?EventArgs?e)
????????{
????????????//如果沒有創建圖像則退出
????????????if?(curBitmap?==?null)
????????????????return;
????????????//調用SaveFileDialog
????????????SaveFileDialog?saveDlg?=?new?SaveFileDialog();
????????????//設置對話框標題
????????????saveDlg.title=“保存為“;
????????????//改寫已經存在文件時提醒用戶
????????????saveDlg.OverwritePrompt?=?true;
????????????//為圖像選擇一個篩選器
????????????saveDlg.Filter?=?“BMP文件(*.bmp)|*.bmp|“?+?“Gif文件(*.gif)|*.gif|“?+?“Tiff文件(*.tif)|*.tif|“?+
????????????????“JPEG文件(*.jpg)|*.jpg|“?+?“PNG文件(*.png)|*.png“;
????????????//啟用“幫助”按鈕
????????????saveDlg.ShowHelp?=?true;
????????????//如果選擇了格式,則保存圖像
????????????if?(saveDlg.ShowDialog()?==?DialogResult.OK)
????????????{
????????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????.CA....???????869??2013-12-16?16:01??第二章.sln
????.CA..H.?????19968??2013-12-20?21:25??第二章.suo
????.CA....?????12800??2013-12-16?17:39??第二章\bin\Debug\第二章.exe
????.CA....?????11600??2013-12-20?20:23??第二章\bin\Debug\第二章.vshost.exe
????.CA....?????10290??2013-12-20?21:25??第二章\Form1.cs
????.CA....??????5764??2013-12-20?21:25??第二章\Form1.Designer.cs
????.CA....??????5817??2013-12-16?17:37??第二章\Form1.resx
????.CA....??????1135??2013-12-20?21:26??第二章\Program.cs
????.CA....??????1380??2013-12-16?16:01??第二章\Properties\AssemblyInfo.cs
????.CA....??????2869??2013-12-16?16:01??第二章\Properties\Resources.Designer.cs
????.CA....??????5612??2013-12-16?16:01??第二章\Properties\Resources.resx
????.CA....??????1095??2013-12-16?16:01??第二章\Properties\Settings.Designer.cs
????.CA....???????249??2013-12-16?16:01??第二章\Properties\Settings.settings
????.CA....??????3899??2013-12-20?21:25??第二章\第二章.csproj
????.C.D...?????????0??2013-12-20?21:26??第二章\bin\Debug
????.C.D...?????????0??2013-12-16?16:01??第二章\bin
????.C.D...?????????0??2013-12-16?16:01??第二章\Properties
????.C.D...?????????0??2013-12-20?21:26??第二章
-----------?---------??----------?-----??----
????????????????83347????????????????????18
評論
共有 條評論