給圖片添加著作權資訊

來源:互聯網
上載者:User

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

                }

            }

        }

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.