资源简介
C#新手,简易的图片编辑器,有几个简单的功能,请多多指教!!!!!
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.IO;
namespace MyPhotoEdit
{
public partial class Form1 : Form
{
Bitmap bits;
private bool b = false;
Point p1;
Point p2;
private Bitmap bt1;
Image img;
private void open()
{
OpenFileDialog ofdlg = new OpenFileDialog();
ofdlg.Filter = “Jpg File(*.jpg)|*.jpg|Bmp File(*.bmp)|*.bmp“;
if (ofdlg.ShowDialog() == DialogResult.OK)
{
Bitmap image = new Bitmap(ofdlg.FileName);
pictureBox1.Image = image;
bits = image;
}
}
private void save()
{
if (this.pictureBox1.Image != null)
{
string str;
Bitmap box1 = new Bitmap(pictureBox1.Image);
Graphics g = this.CreateGraphics();
saveFileDialog1.Filter = “Jpg文件(*.jpg)|*.jpg|bmp文件(*.BMP)|*.BMP|All File(*.*)|*.*|Jpg文件(*.jpg)|*.jpg“;
saveFileDialog1.ShowDialog();
str = saveFileDialog1.FileName;
pictureBox1.Image.Save(str);
}
}
private void heibai()
{
if (this.pictureBox1.Image != null)
{
Color c = new Color();
Bitmap b = new Bitmap(pictureBox1.Image); //把图片框中的图片给一个bitmap 类型
Bitmap b1 = new Bitmap(pictureBox1.Image);
int rr gg bb cc;
for (int i = 0; i < pictureBox1.Width; i++)
{
for (int j = 0; j < pictureBox1.Height; j++)
{
c = b.GetPixel(i j);
rr = c.B;
gg = c.G;
bb = c.B;
cc = (int)((rr + gg + bb) / 3);
if (cc < 0) cc = 0;
if (cc > 255) cc = 255;
Color c1 = Color.FromArgb(cc cc cc);//用formargb把 整形转换成颜色值
b1.SetPixel(i j c1);
}
pictureBox1.Image = b1; //图片赋到图片框中
}
pictureBox1.Refresh(); //刷新
}
}
private void dama()
{
if (this.pictureBox1.Image != null)
{
pictureBox1.Refresh();
Point NBegin = new Point();
Point NEnd = new Point();
Point Bgn_Point = new Point();
Point End_Point = new Point();
if (Bgn_Point.X < End_Point.X)
{
NBegin.X = Bgn_Point.X;
NEnd.X = End_Point.X;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 229376 2010-06-04 18:30 MyPhotoEdit\MyPhotoEdit\bin\Debug\MyPhotoEdit.exe
文件 44544 2010-06-04 18:30 MyPhotoEdit\MyPhotoEdit\bin\Debug\MyPhotoEdit.pdb
文件 5632 2005-12-08 14:51 MyPhotoEdit\MyPhotoEdit\bin\Debug\MyPhotoEdit.vshost.exe
文件 35550 2010-06-04 18:30 MyPhotoEdit\MyPhotoEdit\Form1.cs
文件 24559 2010-06-04 18:30 MyPhotoEdit\MyPhotoEdit\Form1.Designer.cs
文件 296149 2010-06-04 18:30 MyPhotoEdit\MyPhotoEdit\Form1.resx
文件 3229 2010-05-27 20:55 MyPhotoEdit\MyPhotoEdit\MyPhotoEdit.csproj
文件 562 2005-07-10 18:46 MyPhotoEdit\MyPhotoEdit\MyToolbar\about.gif
文件 127438 2004-01-17 02:09 MyPhotoEdit\MyPhotoEdit\MyToolbar\About.ico
文件 2910 2010-05-29 20:07 MyPhotoEdit\MyPhotoEdit\MyToolbar\back06.gif
文件 327 2007-06-16 04:50 MyPhotoEdit\MyPhotoEdit\MyToolbar\backward.gif
文件 46158 2010-05-29 22:57 MyPhotoEdit\MyPhotoEdit\MyToolbar\bian.bmp
文件 5717 2010-05-29 22:49 MyPhotoEdit\MyPhotoEdit\MyToolbar\bian.jpg
文件 131358 2004-01-17 20:40 MyPhotoEdit\MyPhotoEdit\MyToolbar\Check.ico
文件 586 2005-07-10 18:59 MyPhotoEdit\MyPhotoEdit\MyToolbar\clone.gif
文件 127438 2004-01-18 15:18 MyPhotoEdit\MyPhotoEdit\MyToolbar\Close 2.ico
文件 127438 2004-01-18 13:50 MyPhotoEdit\MyPhotoEdit\MyToolbar\Close.ico
文件 337 2005-07-10 19:05 MyPhotoEdit\MyPhotoEdit\MyToolbar\convolution.gif
文件 615 2005-07-10 18:47 MyPhotoEdit\MyPhotoEdit\MyToolbar\copy.gif
文件 127438 2004-01-18 14:34 MyPhotoEdit\MyPhotoEdit\MyToolbar\Copy.ico
文件 561 2005-07-10 18:59 MyPhotoEdit\MyPhotoEdit\MyToolbar\cut.gif
文件 127438 2004-01-18 15:39 MyPhotoEdit\MyPhotoEdit\MyToolbar\Cut.ico
文件 127438 2004-01-16 13:46 MyPhotoEdit\MyPhotoEdit\MyToolbar\Delete 2.ico
文件 127438 2004-01-18 14:25 MyPhotoEdit\MyPhotoEdit\MyToolbar\Delete.ico
文件 1049 2005-07-10 18:47 MyPhotoEdit\MyPhotoEdit\MyToolbar\disk.gif
文件 127438 2004-01-18 14:32 MyPhotoEdit\MyPhotoEdit\MyToolbar\Document.ico
文件 127438 2004-01-16 16:26 MyPhotoEdit\MyPhotoEdit\MyToolbar\Exit.ico
文件 148 2005-07-10 19:02 MyPhotoEdit\MyPhotoEdit\MyToolbar\fit_to_size.gif
文件 216 2007-06-16 04:50 MyPhotoEdit\MyPhotoEdit\MyToolbar\folder.gif
文件 1024 2005-07-10 18:46 MyPhotoEdit\MyPhotoEdit\MyToolbar\folder_out.gif
............此处省略56个文件信息
评论
共有 条评论