C#中图片操作
来源:互联网 发布:中差评师拦截功能软件 编辑:程序博客网 时间:2024/04/29 08:27
//选择图片并显示
private void btnCaseAddPic_Click(object sender, System.EventArgs e)
{
openFileDialog1.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif";
openFileDialog1.FilterIndex = 0;
openFileDialog1.Title = "选择照片";
affixInfo = new AffixInfo();
if (openFileDialog1.ShowDialog() ==DialogResult.OK)
{
//取文件名
affixInfo.FileName = openFileDialog1.FileName;
while(affixInfo.FileName.IndexOf("//") != -1)
{
affixInfo.FileName = affixInfo.FileName.Substring(affixInfo.FileName.IndexOf("//")+1);
}
//取文件扩展名
affixInfo.FileExt = affixInfo.FileName.Substring(affixInfo.FileName.LastIndexOf(".")+1);
if(affixInfo.FileName.Length != 0)
{
//读取图片
FileStream fs = (FileStream)openFileDialog1.OpenFile();
byte[] content = new byte[fs.Length];
fs.Read(content, 0,content.Length);
affixInfo.FileImage = content;
affixInfo.FileSize = Convert.ToInt32(fs.Length);
//显示图片
//Stream stream = new MemoryStream(content, true);
//stream.Write(content, 0, content.Length);
Image bmp = new Bitmap(fs);
//stream.Close();
pbxCasePic.Image = bmp;
//设置查看图片按钮可用
this.btnCaseLookPic.Enabled = true;
}//endif
}
}
//启动系统默认应用程序查看图片
private void btnCaseLookPic_Click(object sender, System.EventArgs e)
{
if (affixInfo.FileName != null)
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = true;
process.StartInfo.FileName = affixInfo.FileName;
process.Start();
}
else
{
MessageBox.Show("请正确选择图片文件!","提示");
}
}
private void btnCaseAddPic_Click(object sender, System.EventArgs e)
{
openFileDialog1.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif";
openFileDialog1.FilterIndex = 0;
openFileDialog1.Title = "选择照片";
affixInfo = new AffixInfo();
if (openFileDialog1.ShowDialog() ==DialogResult.OK)
{
//取文件名
affixInfo.FileName = openFileDialog1.FileName;
while(affixInfo.FileName.IndexOf("//") != -1)
{
affixInfo.FileName = affixInfo.FileName.Substring(affixInfo.FileName.IndexOf("//")+1);
}
//取文件扩展名
affixInfo.FileExt = affixInfo.FileName.Substring(affixInfo.FileName.LastIndexOf(".")+1);
if(affixInfo.FileName.Length != 0)
{
//读取图片
FileStream fs = (FileStream)openFileDialog1.OpenFile();
byte[] content = new byte[fs.Length];
fs.Read(content, 0,content.Length);
affixInfo.FileImage = content;
affixInfo.FileSize = Convert.ToInt32(fs.Length);
//显示图片
//Stream stream = new MemoryStream(content, true);
//stream.Write(content, 0, content.Length);
Image bmp = new Bitmap(fs);
//stream.Close();
pbxCasePic.Image = bmp;
//设置查看图片按钮可用
this.btnCaseLookPic.Enabled = true;
}//endif
}
}
//启动系统默认应用程序查看图片
private void btnCaseLookPic_Click(object sender, System.EventArgs e)
{
if (affixInfo.FileName != null)
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = true;
process.StartInfo.FileName = affixInfo.FileName;
process.Start();
}
else
{
MessageBox.Show("请正确选择图片文件!","提示");
}
}
- C#中图片操作
- C#操作数据库中存取图片文件
- c#操作sql中存取图片image
- C#中关于图片的几个操作
- C#操作图片
- C#中操作图片出现资源被占用
- C#中操作Excel(3)—— Excel中操作文本、图片和批注
- C# .net 对图片操作
- c# 指针方式操作图片
- C#对图片的操作
- C#中图片透明
- C#中打开图片
- android中操作图片
- C#中操作Word(6)—— 如何向Word中插入图片
- C# 中操作API:
- C# 中操作API
- C#中操作注册表
- c#中操作注册表
- 学习.Net的经典网站
- EJB3.0消息驱动Bean
- ado.net c#.net2005 From第一讲(BindingDemoForm3)
- mysql latin to utf8
- ExceptionInInitializerError();
- C#中图片操作
- linux内核从2.4.20-8升级到2.6.0版本步骤
- 几种代价函数
- EJB3.0实体Bean(一)
- EJB3.0实体Bean(二)
- 关于数据恢复技术
- InfoQ--Visual Studio 2008和.NET 3.5 Beta 2发布
- 一个简单的EJB-Session Bean实例
- EJB3.0实体Bean(三)