zoukankan      html  css  js  c++  java
  • 图形技术(在图片中写入文字)


      string str;
           //在图片中绘制文字

           private void button1_Click(object sender, EventArgs e)
            {
                try
                {
                    Image myImage = System.Drawing.Image.FromFile(str);
                    Bitmap map = new Bitmap(myImage);
                    myImage.Dispose();
                    Graphics graphics = Graphics.FromImage(map);
                    graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
                    SolidBrush brush = new SolidBrush(Color.Red);
                    PointF P = new PointF(50, 50);
                    Font font = new Font(this.Font.Name, 40);
                    graphics.DrawString(textBox1.Text, font, brush, P);
                    map.Save(str.Substring(0, str.LastIndexOf("\\") + 1) + "new" + str.Substring(str.LastIndexOf("\\") + 1, str.LastIndexOf(".") - str.LastIndexOf("\\") - 1) + str.Substring(str.LastIndexOf("."), str.Length - str.LastIndexOf(".")), ImageFormat.Jpeg);
                    MessageBox.Show("写入成功");
                    font.Dispose();
                    graphics.Dispose();
                }
                catch { }
            }
            //选择图片
            private void button2_Click(object sender, EventArgs e)
            {
                try
                {
                    openFileDialog1.Filter = "JPG文件(*.jpg)|*.jpg";
                    openFileDialog1.ShowDialog();
                    str = openFileDialog1.FileName;
                    Image myImage = System.Drawing.Image.FromFile(str);
                    this.pictureBox1.Image = myImage;
                }
                catch { }
            }

  • 相关阅读:
    FireGestures 火狐手势插件 使用
    计算分段采样区间中的平均值,标准差,中位数,积分值等的类
    DWR与Spring结合
    项目总结
    在线机器学习算法及其伪代码
    Hdu 1394 Minimum Inversion Number、Poj 2299 UltraQuickSort
    Ubuntn 安装sendmail并把硬盘空间信息发送到指定邮箱
    iPhone应用程序开发使用Core Data (一)
    [置顶] C++里被人遗忘的智能指针
    HTML标签p和div的不同
  • 原文地址:https://www.cnblogs.com/msAspnet/p/2097181.html
Copyright © 2011-2022 走看看