给图片添加版权信息

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();

                }

            }

        }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值