![簡(jiǎn)易圖像編輯及制作軟件_第1頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-1/18/662d98fe-70c3-4cd2-a995-d2117e14a6b7/662d98fe-70c3-4cd2-a995-d2117e14a6b71.gif)
![簡(jiǎn)易圖像編輯及制作軟件_第2頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-1/18/662d98fe-70c3-4cd2-a995-d2117e14a6b7/662d98fe-70c3-4cd2-a995-d2117e14a6b72.gif)
![簡(jiǎn)易圖像編輯及制作軟件_第3頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-1/18/662d98fe-70c3-4cd2-a995-d2117e14a6b7/662d98fe-70c3-4cd2-a995-d2117e14a6b73.gif)
![簡(jiǎn)易圖像編輯及制作軟件_第4頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-1/18/662d98fe-70c3-4cd2-a995-d2117e14a6b7/662d98fe-70c3-4cd2-a995-d2117e14a6b74.gif)
![簡(jiǎn)易圖像編輯及制作軟件_第5頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-1/18/662d98fe-70c3-4cd2-a995-d2117e14a6b7/662d98fe-70c3-4cd2-a995-d2117e14a6b75.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、C#.NET課程設(shè)計(jì)實(shí)驗(yàn)報(bào)告班級(jí):計(jì)算機(jī)1302 姓名:吳秀文 學(xué)號(hào):201320100218 題目:簡(jiǎn)易圖像編輯與制作軟件的實(shí)現(xiàn)目的:(1) 采用C#制作一個(gè)簡(jiǎn)易的圖像編輯與制作軟件,鞏固C#的知識(shí)。(2) 培養(yǎng)學(xué)生獨(dú)立完成C#項(xiàng)目的開發(fā)經(jīng)驗(yàn)。任務(wù)要求:(1) 圖像編輯:1) 打開要編輯的圖片,并顯示初始圖像:包括從菜單的“打開”項(xiàng),工具欄“打開”按鈕和系統(tǒng)打開方式(即在我的電腦里,選中圖片文件后,右建打開方式選擇本軟件打開圖片),以及拖放打開方式(即將圖片拖動(dòng)到打開的軟件界面,就將該圖打開顯示)四種打開圖片的功能均需實(shí)現(xiàn)。2) 顯示功能:圖像放大,縮小,實(shí)際大小3) 圖像編輯:水平翻轉(zhuǎn),垂
2、直翻轉(zhuǎn),順時(shí)針旋轉(zhuǎn)90度,逆時(shí)針旋轉(zhuǎn)90度,反色,浮雕,黑白,柔化,銳化,灰度化,霧化,馬賽克效果,設(shè)置圖像像素大小。(2) 圖片制作:1) 新建圖像;2) 繪制直線,弧線,曲線,空心矩形,實(shí)心矩形,空心橢圓,實(shí)心橢圓,多邊形,實(shí)心多邊形,文本;3) 線型設(shè)置:實(shí)線,虛線,線條粗細(xì),線條始止端點(diǎn)的形狀4) 顏色設(shè)置:設(shè)置線或?qū)嵭男螤罨蜃煮w的顏色,包括純色(solidbrush);漸變色(漸變畫筆);設(shè)置紋理(陰影畫筆);設(shè)置填充圖片(紋理畫筆)(3) 保存:對(duì)新建的圖像,保存時(shí)選擇路徑,圖片格式,文件名,然后保存。否則直接保存圖象。(4) 另存為:選擇路徑,圖片格式,文件名,然后保存圖像。(5
3、) 菜單和工具欄:軟件需要有菜單和工具欄快捷按鈕,菜單包括所有功能,工具欄可以設(shè)置最常用的快捷按鈕以上是軟件需要實(shí)現(xiàn)的基本功能,但可以自行新增一些功能和繪制圖形。對(duì)于保存和打開圖片功能,一般可設(shè)置支持BMP,JPG,PNG,GIF,TIFF,ICON格式。實(shí)驗(yàn)步驟:1、前期工作1.1新建Windows應(yīng)用程序項(xiàng)目:wuxiuwen,重命名form1,wxw_Form1.cs。1.2 界面制作1.3 添加主界面form類的數(shù)據(jù)成員 private Bitmap img = null; private string fullname = null;/圖像文件完整路徑 private int tem
4、pWidth, tempHeight;/圖像變化信息,寬高屬性 private Color c;/前景色 Color c1;/純色;或漸變色的始止顏色;或者紋理的前景色和背景色 private Color startcolor, endcolor;/用戶設(shè)置前景色與背景色 DashStyle line_type; /線型 LineCap StartCap, EndCap;/起始端點(diǎn)形狀,結(jié)束端點(diǎn)形狀 int colortype;/1 純色,2 漸變色,3 紋理,4 圖片填充 LinearGradientMode lgm;/漸變方向 HatchStyle hs; /紋理類型 Bitmap fil
5、l_img;/填充圖片 int lineheight;/線寬 Pen pen;/鋼筆 SolidBrush sb;/純色畫筆 LinearGradientBrush lgb;/漸變畫筆 HatchBrush hb;/陰影畫筆,可畫紋理效果 TextureBrush tb;/紋理畫筆,可用于圖片填充 int drawselect = 0;/繪制圖形選項(xiàng),1直線,2曲線,3弧線 4空心矩形,5實(shí)心矩形,6 空心橢圓,7實(shí)心橢圓,8空心多邊形,9實(shí)心多邊形,10 文本 Point startpoint;/繪制的起始點(diǎn) Point targetPoint;/終點(diǎn) bool domousemove =
6、false;/ 判斷標(biāo)記,是否為繪制時(shí)的鼠標(biāo)移動(dòng) ArrayList arrayPoint = new ArrayList();/存放繪制過程中的多個(gè)點(diǎn)的動(dòng)態(tài)數(shù)組 string drawstring = ; /繪制的文本 Font myfont = new Font(宋體, 12);/繪制文本的字體1.4 設(shè)置屬性 public int ImageWidth/圖片寬構(gòu)造函數(shù) get return img.Width; set tempWidth = value; public int ImageHeight/圖片高構(gòu)造函數(shù) get return img.Height; set tempHeig
7、ht = value; public Color startColor/前景色屬性設(shè)置函數(shù) get return c; set c = value; public Color commonColor /純色;或漸變色的始止顏色;或者紋理的前景色和背景色 get return c1; set c1 = value; public int ColorType get return colortype; set colortype = value; public Color StartColor /前景色 get return startcolor; set startcolor = value;
8、public Color EndColor/背景色 get return endcolor; set endcolor = value; public HatchStyle HS/紋理樣式 get return hs; set hs = value; public const int Rotate180FlipY = 0;/水平旋轉(zhuǎn) public const int Rotate180FlipX = 1; /垂直旋轉(zhuǎn) public const int Rotate90FlipNone = 2;/順時(shí)針 public const int Rotate270FlipNone = 3; /逆時(shí)針旋轉(zhuǎn)
9、901.5 主界面 Form1_Load方法中進(jìn)行數(shù)據(jù)的必要初始化操作 c = Color.Blue; c1 = Color.Green; line_type = DashStyle.Solid; startcolor = Color.Yellow; endcolor = Color.Green; colortype = 1; StartCap = LineCap.NoAnchor; EndCap = LineCap.NoAnchor; lgm = LinearGradientMode.Horizontal; hs = HatchStyle.DashedHorizontal; img = ne
10、w Bitmap(pictureBox1.Width, pictureBox1.Height); Graphics g = Graphics.FromImage(img); sb = new SolidBrush(Color.White); g.FillRectangle(sb, 0, 0, pictureBox1.Width, pictureBox1.Height); pictureBox1.Image = img; if (fullname != null & !fullname.Equals() Bitmap tempImage = new Bitmap(fullname); img =
11、 new Bitmap(tempImage.Width, tempImage.Height); Graphics draw = Graphics.FromImage(img); draw.DrawImage(tempImage, 0, 0, tempImage.Width, tempImage.Height); pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize; pictureBox1.Image = img; draw.Dispose(); tempImage.Dispose(); 添加系統(tǒng)命名空間using System.Collecti
12、ons;using System.Drawing.Imaging;using System.Drawing.Drawing2D;2、圖像編輯2.1點(diǎn)擊菜單欄的打開 /增加帶參數(shù)的構(gòu)造方法 public wxw_Form1(string a) InitializeComponent(); fullname = a; private void 打開ToolStripMenuItem_Click(object sender, EventArgs e) OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = bmp,jpg,gif,p
13、ng,tiff,icon|*.bmp;*.jpg;*.gif;*.png;*.tiff;*.icon; dialog.Title = 選擇圖片; if (dialog.ShowDialog() = DialogResult.OK) Bitmap tempImage = new Bitmap(dialog.FileName); img = new Bitmap(tempImage.Width, tempImage.Height); Graphics draw = Graphics.FromImage(img); draw.DrawImage(tempImage, 0, 0, tempImage.
14、Width, tempImage.Height); fullname = dialog.FileName.ToString(); pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize; pictureBox1.Image = img; draw.Dispose(); tempImage.Dispose(); 2.2 圖像顯示功能2.2.1圖像實(shí)際大小顯示:Dock必須設(shè)置為None,否則圖像放大與縮小將失效 private void 實(shí)際大小ToolStripMenuItem_Click(object sender, EventArgs e) p
15、ictureBox1.SizeMode = PictureBoxSizeMode.AutoSize; 2.2.2放大圖像的顯示比例 private void 放大ToolStripMenuItem_Click(object sender, EventArgs e) pictureBox1.Height = (int)Math.Ceiling(pictureBox1.Height * 1.1); pictureBox1.Width = (int)Math.Ceiling(pictureBox1.Width * 1.1); pictureBox1.SizeMode = PictureBoxSize
16、Mode.Zoom; 2.2.3 縮小圖像的顯示比例 private void 縮小ToolStripMenuItem_Click(object sender, EventArgs e) pictureBox1.Height = (int)Math.Ceiling(pictureBox1.Height * 0.9); pictureBox1.Width = (int)Math.Ceiling(pictureBox1.Width * 0.9); pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; 2.3圖像編輯2.3.1設(shè)置圖像像素大小新建圖像編輯界面
17、:wxw_setsize_Form1.cs private wxw_Form1 sizeForm; /確認(rèn)按鈕 private void button1_Click(object sender, EventArgs e) if (myWidthTB.Text.Equals() | myHeightTB.Text.Equals() MessageBox.Show(高度與寬度不能為空, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information); return; sizeForm.ImageWidth = int.Parse(myWidthTB.Te
18、xt.ToString(); sizeForm.ImageHeight = int.Parse(myHeightTB.Text.ToString(); this.Close(); /取消按鈕 private void button2_Click(object sender, EventArgs e) this.Close(); private void wxw_setsize_Form1_Load(object sender, EventArgs e) sizeForm = (wxw_Form1)this.Owner; currWidthLabel.Text = sizeForm.ImageW
19、idth.ToString(); currHeightLabel.Text = sizeForm.ImageHeight.ToString(); 在主程序中添加代碼 private void 圖像大小設(shè)置ToolStripMenuItem_Click(object sender, EventArgs e) if (img = null) MessageBox.Show(未打開任何圖片, 提示, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; tempWidth = img.Width;/賦值給寬的全局變量 tempHeight =
20、img.Height;/賦值給高的全局變量 wxw_setsize_Form1 sizeForm = new wxw_setsize_Form1(); sizeForm.Owner = this; sizeForm.ShowDialog(); if (tempHeight != img.Height | tempWidth != img.Width) Bitmap tempImage = new Bitmap(tempWidth, tempHeight); Graphics draw = Graphics.FromImage(tempImage); draw.DrawImage(img, 0,
21、 0, tempImage.Width, tempImage.Height); img = tempImage; pictureBox1.Image = img; pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize; 2.3.2翻轉(zhuǎn)設(shè)置private void convertBitmap(int rotate180FlipY) if (img = null) MessageBox.Show(未打開任何圖片, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information); return; tempWi
22、dth = img.Width;/賦值給寬的全局變量 tempHeight = img.Height;/賦值給高的全局變量 Bitmap tempImage = new Bitmap(tempWidth, tempHeight); Graphics draw = Graphics.FromImage(tempImage); switch (rotate180FlipY) case Rotate180FlipY: /水平旋轉(zhuǎn) img.RotateFlip(RotateFlipType.Rotate180FlipY); break; case Rotate180FlipX: /垂直翻轉(zhuǎn) img.R
23、otateFlip(RotateFlipType.Rotate180FlipX); break; case Rotate90FlipNone: /順時(shí)針翻轉(zhuǎn) img.RotateFlip(RotateFlipType.Rotate90FlipNone); break; case Rotate270FlipNone: /逆時(shí)針翻轉(zhuǎn) img.RotateFlip(RotateFlipType.Rotate270FlipNone); break; draw.DrawImage(img, 0, 0, tempImage.Width, tempImage.Height); img = tempImage
24、; pictureBox1.Image = img; pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize; 2.3.3 水平翻轉(zhuǎn)設(shè)置 private void 水平翻轉(zhuǎn)ToolStripMenuItem_Click(object sender, EventArgs e) this.convertBitmap(Rotate180FlipY); 2.3.4 垂直翻轉(zhuǎn) private void 垂直翻轉(zhuǎn)ToolStripMenuItem_Click(object sender, EventArgs e) this.convertBitmap(Rota
25、te180FlipX); 2.3.5順時(shí)針旋轉(zhuǎn) private void 順時(shí)針旋轉(zhuǎn)90度ToolStripMenuItem_Click(object sender, EventArgs e) this.convertBitmap(Rotate90FlipNone); 2.3.6逆時(shí)針旋轉(zhuǎn) private void 逆時(shí)針旋轉(zhuǎn)90度ToolStripMenuItem_Click(object sender, EventArgs e) this.convertBitmap(Rotate90FlipNone); 3、 圖片制作3.1 新建圖像private void 新建ToolStripMenu
26、Item_Click(object sender, EventArgs e) img = new Bitmap(pictureBox1.Width, pictureBox1.Height); Graphics g = Graphics.FromImage(img); sb = new SolidBrush(Color.White); g.FillRectangle(sb, 0, 0, pictureBox1.Width, pictureBox1.Height); pictureBox1.Image = img; 3.2 繪制工具取消繪制private void toolStripButton1
27、8_Click(object sender, EventArgs e) drawselect = 0; this.Cursor = Cursors.Default; 繪制直線private void toolStripButton19_Click(object sender, EventArgs e) drawselect = 1; this.Cursor = Cursors.Cross; 弧線private void toolStripButton21_Click(object sender, EventArgs e) drawselect = 3; this.Cursor = Cursor
28、s.Cross; 曲線 private void toolStripButton20_Click(object sender, EventArgs e) drawselect = 1; this.Cursor = Cursors.Cross; 空心矩形 private void toolStripButton22_Click(object sender, EventArgs e) drawselect = 4; this.Cursor = Cursors.Cross; 實(shí)心矩形private void toolStripButton23_Click(object sender, EventAr
29、gs e) drawselect = 5; this.Cursor = Cursors.Cross; 空心橢圓 private void toolStripButton24_Click(object sender, EventArgs e) drawselect = 6; this.Cursor = Cursors.Cross; 實(shí)心橢圓private void toolStripButton25_Click(object sender, EventArgs e) drawselect = 7; this.Cursor = Cursors.Cross; 空心多邊形private void to
30、olStripButton26_Click(object sender, EventArgs e) drawselect = 8; this.Cursor = Cursors.Cross; 實(shí)心多邊形private void toolStripButton27_Click(object sender, EventArgs e) drawselect = 9; this.Cursor = Cursors.Cross; 文本 private void toolStripButton28_Click(object sender, EventArgs e) drawselect = 10; this.
31、Cursor = Cursors.Cross; 繪制需要繪制工具與鼠標(biāo)配合using System.Drawing.Drawing2D;namespace wuxiuwen / 鼠標(biāo)狀態(tài)類型 public enum MouseStateType MouseDown, MouseMove, MouseUp class ToolUtils /繪制多邊形 public static void DrawPolygon(Graphics g, Point p, Boolean isFill, Pen pen, Color c) GraphicsPath tempGraphicsPath = new Gr
32、aphicsPath(); if (p.Length 1) tempGraphicsPath.AddLines(p.ToArray(); if (isFill) g.FillPath(new SolidBrush(c), tempGraphicsPath); g.DrawPath(pen, tempGraphicsPath); 鼠標(biāo)的點(diǎn)擊、移動(dòng)、雙擊等操作 / 鼠標(biāo)雙擊 private void pictureBox1_MouseDoubleClick(object sender, MouseEventArgs e) if (domousemove = false) return; pictu
33、reBox1.Image = this.img; Graphics g = Graphics.FromImage(pictureBox1.Image); pen = new Pen(c, float.Parse(toolStripComboBox1.Text); pen.DashStyle = line_type; pen.StartCap = StartCap; pen.EndCap = EndCap; switch (drawselect) case 2: /曲線 arrayPoint.RemoveAt(arrayPoint.Count - 1); Point drawPoint = ne
34、w PointarrayPoint.Count; int i = 0; foreach (Point p in arrayPoint) drawPointi+ = p; g.DrawCurve(pen, drawPoint); break; case 3: /弧線 if (arrayPoint.Count 4) return; arrayPoint.RemoveAt(arrayPoint.Count - 1); Point drawPoint = new PointarrayPoint.Count; int i = 0; foreach (Point p in arrayPoint) draw
35、Pointi+ = p; g.DrawBezier(pen, drawPoint0, drawPoint1, drawPoint2, drawPoint3); break; case 8: /空心多邊形 arrayPoint.RemoveAt(arrayPoint.Count - 1); Point drawPoint = new PointarrayPoint.Count; int i = 0; foreach (Point p in arrayPoint) drawPointi+ = p; ToolUtils.DrawPolygon(g, drawPoint, false, pen, c)
36、; break; case 9: /實(shí)心多邊形 arrayPoint.RemoveAt(arrayPoint.Count - 1); Point drawPoint = new PointarrayPoint.Count; int i = 0; foreach (Point p in arrayPoint) drawPointi+ = p; ToolUtils.DrawPolygon(g, drawPoint, true, pen, c); break; domousemove = false; drawselect = 0; this.Cursor = Cursors.Default; ar
37、rayPoint.Clear(); g.Dispose(); /按下鼠標(biāo) private void pictureBox1_MouseDown(object sender, MouseEventArgs e) if (drawselect = 0) return; startpoint = new Point(e.X, e.Y); targetPoint = new Point(e.X, e.Y); arrayPoint.Add(startpoint);/起點(diǎn)加入點(diǎn)陣數(shù)組 domousemove = true;/繪制圖形開始 pictureBox1.Image = (Bitmap)this.i
38、mg.Clone(); Graphics g = Graphics.FromImage(pictureBox1.Image); switch (drawselect) case 10: if (alphaTextBox.Visible) for (int i = 0; i alphaTextBox.Lines.Length; +i) Point newLocation = new Point(alphaTextBox.Location.X, alphaTextBox.Location.Y + i * (alphaTextBox.Font.Height - 5); g.DrawString(al
39、phaTextBox.Linesi, alphaTextBox.Font, new SolidBrush(Color.FromArgb(255, alphaTextBox.ForeColor), newLocation); alphaTextBox.Text = ; alphaTextBox.Visible = false; else alphaTextBox.Location = startpoint; alphaTextBox.ForeColor = c; alphaTextBox.Font = new Font(alphaTextBox.Font.FontFamily, 22, alphaTextBox.Font.Style); alphaTextBox.Visible = true; break; /鼠標(biāo)拖動(dòng) private void pictureBox1_MouseMove(object sender,
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年船舶潤(rùn)滑油供應(yīng)合同
- 2025年機(jī)關(guān)單位臨時(shí)工兼職人員合同
- 2025年積分銷售合同協(xié)議書示例
- 2025年醫(yī)療設(shè)備策劃合作租賃與銷售框架合同
- 2025年住宅項(xiàng)目園林景觀設(shè)計(jì)合同
- 2025年農(nóng)地耕作權(quán)交換協(xié)議
- 2025年專利技術(shù)合同爭(zhēng)議處理方法
- 2025年企業(yè)資產(chǎn)重組授權(quán)代理協(xié)議指導(dǎo)
- 2025年智能穿戴項(xiàng)目申請(qǐng)報(bào)告模式
- 2025年共同投資合作成果合作協(xié)議書
- 高教社新國(guó)規(guī)中職英語教材《英語2基礎(chǔ)模塊》英語2-U3-1.0
- 2023版設(shè)備管理體系標(biāo)準(zhǔn)
- 《工程款糾紛》課件
- 中建地下管廊豎井及矩形頂管專項(xiàng)施工方案
- 第7課互聯(lián)網(wǎng)應(yīng)用協(xié)議 課件 2023-2024學(xué)年浙教版(2023)初中信息技術(shù)七年級(jí)上冊(cè)
- 關(guān)于新能源汽車的論文1500字
- 診所規(guī)章制度匯編全套
- 中國(guó)音樂學(xué)院音樂基礎(chǔ)知識(shí)(四級(jí))(基本樂科)備考試題庫(kù)(含答案)
- 學(xué)校校長(zhǎng)思政課講稿共五篇
- 有限公司事業(yè)合伙人管理辦法
- 演示文稿國(guó)庫(kù)集中支付總流程圖
評(píng)論
0/150
提交評(píng)論