给图片添加版权信息
2004-08-17 14:26
393 查看
Bitmap bitmap=new Bitmap(this.pictureBox2.Width,this.pictureBox2.Height,System.Drawing.Imaging.PixelFormat.Format24bppRgb);
//根据位图获取画布
Graphics g=Graphics.FromImage(bitmap);
//清空画布并用透明色填充
g.Clear(Color.Transparent);
//将另一幅图片画到画布上
g.DrawImage(this.pictureBox1.Image,0,0);
//写版权信息到图片上。
g.DrawString(this.textBox2.Text,new Font("黑体",15),new SolidBrush(Color.Red),new Rectangle(20,20,100,100));
//显示
this.pictureBox2.Image=bitmap;
//保存图片
bitmap.Save("c://abc.bmp",System.Drawing.Imaging.ImageFormat.Bmp);
顺便帖一下“选择”按钮的单击事件程序:
private void button1_Click(object sender, System.EventArgs e)
{
if(this.openFileDialog1.ShowDialog()==DialogResult.OK)
{
if(this.openFileDialog1.FileName.Length==0)
{
MessageBox.Show("请选择图片","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
return;
}
this.textBox1.Text=this.openFileDialog1.FileName;
FileStream fs=new FileStream(this.openFileDialog1.FileName,FileMode.Open,FileAccess.Read);
try
{
this.pictureBox1.Image=Image.FromStream(fs);
}
catch(Exception)
{
MessageBox.Show("您选择的文件不是可识别的图片格式","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
finally
{
fs.Close();
}
}
}
//根据位图获取画布
Graphics g=Graphics.FromImage(bitmap);
//清空画布并用透明色填充
g.Clear(Color.Transparent);
//将另一幅图片画到画布上
g.DrawImage(this.pictureBox1.Image,0,0);
//写版权信息到图片上。
g.DrawString(this.textBox2.Text,new Font("黑体",15),new SolidBrush(Color.Red),new Rectangle(20,20,100,100));
//显示
this.pictureBox2.Image=bitmap;
//保存图片
bitmap.Save("c://abc.bmp",System.Drawing.Imaging.ImageFormat.Bmp);
顺便帖一下“选择”按钮的单击事件程序:
private void button1_Click(object sender, System.EventArgs e)
{
if(this.openFileDialog1.ShowDialog()==DialogResult.OK)
{
if(this.openFileDialog1.FileName.Length==0)
{
MessageBox.Show("请选择图片","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
return;
}
this.textBox1.Text=this.openFileDialog1.FileName;
FileStream fs=new FileStream(this.openFileDialog1.FileName,FileMode.Open,FileAccess.Read);
try
{
this.pictureBox1.Image=Image.FromStream(fs);
}
catch(Exception)
{
MessageBox.Show("您选择的文件不是可识别的图片格式","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
finally
{
fs.Close();
}
}
}
相关文章推荐
- 给图片添加版权信息(C#)
- C#给图片添加版权信息
- 给图片添加版权信息(C#) [转帖]
- 给图片添加版权信息(C#)
- C#给图片添加版权信息
- Vim中自动在程序起始处添加版权和作者信息
- 用ASP.NET上传图片并生成可带版权信息的缩略图
- “MVC+Nhibernate+Jquery-EasyUI” 信息发布系统 第六篇(图片新闻的添加以及带分页的静态页的生成)
- 如何给Openlayers添加版权信息
- 用ASP.NET上传图片并生成带版权信息的缩略图
- asp.net为图片增加自己的版权信息
- 把文本信息以隐藏的方式添加到图片文件中
- 复制内容添加版权信息
- 织梦底部添加版权信息标签代码
- DIV+CSS实操三:经管系网页内容模块添加标题栏和版权信息模块
- 用ASP.NET上传图片并生成带版权信息的缩略图
- winform壁纸工具为图片添加当前月的日历信息
- 为VS2010默认模板添加版权信息
- 如何将自己的代码自动添加版权信息
- 为VisualStudio默认模板添加版权信息