找传奇、传世资源到传世资源站!

C# 图片编辑工具源码(图片处理程序)

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

图片处理程序,打开任意一张图片后 可在其上编辑,并保存
from clipboardfrom clipboardusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace PictureEditApp{ public partial class frmImageEdit : DevExpress.XtraEditors.XtraForm { public frmImageEdit() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { for(int i=1;i<201;i ) { repositoryItemComboBox1.Items.Add(i); } pictureEdit1.Init(null); pictureEdit1.ZoomPercentChange = PictureEdit1_ZoomPercentChange; pictureEdit1.zoomImage(100F); } private void PictureEdit1_ZoomPercentChange(object sender, EventArgs e) { item_Size.EditValue = pictureEdit1.zoomPercent.ToString(); } /// <summary> /// 打开 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_Open_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { OpenFileDialog fd = new OpenFileDialog(); if (fd.ShowDialog() == DialogResult.OK) { pictureEdit1.Open(fd.FileName); } } public Image image { get { return pictureEdit1.Image; } set { pictureEdit1.Image = value; } } public void setEditModule(String module) { if(module == "edit") { this.Btn_Open.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; } else if (module == "view") { this.Btn_Open.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; this.Btn_Save.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; ribbonPageGroup2.Visible = false; } } /// <summary> /// 选择 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_Select_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { pictureEdit1.onSelect_Click(); } /// <summary> /// 矩形 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_rectangle_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { pictureEdit1.onRectangle_Click(); } /// <summary> /// 圆形 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_Circle_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { pictureEdit1.onRoundness_Click(); } /// <summary> /// 箭头 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_arrow_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { pictureEdit1.onArrow_Click(); } /// <summary> /// 文字 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_Font_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { pictureEdit1.onWord_Click(); } /// <summary> /// 画笔 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_Paint_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { pictureEdit1.onPen_Click(); } /// <summary> /// 裁剪 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_Cut_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { pictureEdit1.onCutPic_Click(); } /// <summary> /// 重置 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_reset_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { pictureEdit1.onSetSize_Click(); } /// <summary> /// 画笔粗细切换事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void repositoryItemComboBox1_SelectedIndexChanged(object sender, EventArgs e) { var comboBoxEdit = sender as DevExpress.XtraEditors.ComboBoxEdit; var item = comboBoxEdit.SelectedItem; if (item_Size.EditValue != null) pictureEdit1.zoomImage((Convert.ToInt32(item)) * 1.0f); } #region 画笔粗细切换调用 private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { pictureEdit1.ChangePenWidth(1); } private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { pictureEdit1.ChangePenWidth(3); } private void barButtonItem4_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { pictureEdit1.ChangePenWidth(5); } private void barButtonItem5_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { pictureEdit1.ChangePenWidth(8); } #endregion /// <summary> /// 颜色切换事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void repositoryItemColorEdit1_ColorChanged(object sender, EventArgs e) { var colorEdit = sender as DevExpress.XtraEditors.ColorEdit; pictureEdit1.ChangePenColor(colorEdit.Color); } /// <summary> /// 只显示裁剪后的图片 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_CutSelect_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { pictureEdit1.onCutPic_Click(); } /// <summary> /// 恢复原图 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_SourceImage_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (pictureEdit1.ImagePic.Image == null) { return; } //this.pictureEdit1.ImagePic.Width = pictureEdit1.sourceImage.Width; //this.pictureEdit1.ImagePic.Height = pictureEdit1.sourceImage.Height; //this.pictureEdit1.ImagePic.Image = pictureEdit1.sourceImage; pictureEdit1.GoBack();//返回集合里的上一张图片,即 撤销操作 } /// <summary> /// 顺时针旋转90度 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_clockwise_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (pictureEdit1.ImagePic.Image == null) { return; } Bitmap bitmap_ = new Bitmap(pictureEdit1.ImagePic.Image); //当前图 bitmap_.RotateFlip(RotateFlipType.Rotate90FlipNone); pictureEdit1.ImagePic.Image = bitmap_; } /// <summary> /// 逆时针旋转90度 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_anticlockwise_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (pictureEdit1.ImagePic.Image == null) { return; } Bitmap bitmap_ = new Bitmap(pictureEdit1.ImagePic.Image); //当前图 bitmap_.RotateFlip(RotateFlipType.Rotate270FlipNone); pictureEdit1.ImagePic.Image = bitmap_; } private void Btn_Save_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { this.DialogResult = DialogResult.OK; this.Close(); } }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复