zoukankan      html  css  js  c++  java
  • 将文字转换为文字图片实现方法

     

       //把文字转换成图片
                if (!string.IsNullOrEmpty(present_no)) //如果文字不为空
                {
                    try
                    {
                        if (!Directory.Exists(@sinpath))
                        {
                            Directory.CreateDirectory(@sinpath); //用于存在图片的路径不存在,则先生成。
                        }
                        //图片对象  初始化图片的宽度与高度           
                        System.Drawing.Bitmap image = new System.Drawing.Bitmap(150, 30);
                        //画板
                        Graphics g = Graphics.FromImage(image);
                        //文本样式
                        //Font font = new System.Drawing.Font("Arial", 12, (System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic));
                        Font font = new System.Drawing.Font("Arial", 10, (System.Drawing.FontStyle.Regular));
                        //文本颜色与纹理
                        //System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0,0, image.Width, image.Height), Color.Red, Color.Red,0, true);
                        SolidBrush drawBrush = new SolidBrush(Color.Red); //文字颜色
                        g.FillRectangle(new SolidBrush(Color.White), 0, 0, image.Width, image.Height);

                        //g.DrawString(wordstring要绘制的文本, font, brush, 2, 2);
                        //image.Save(filename保存路径)
                        g.DrawString(pnName, font, drawBrush, 5, 5);
                        string path = sinpath + "\" + present_no + ".jpg";
                        image.Save(path, System.Drawing.Imaging.ImageFormat.Jpeg);
                    }
                    catch (Exception ex)
                    {
                        throw ex;                   
                    }

           }

  • 相关阅读:
    ubuntu root 登录没有声音(waiting for sound system to respond)
    android openVG source prj
    http://source.android.com/ android官网(下载源码及sdk)
    8个优秀的Android开源游戏引擎
    2010開放原始碼創新應用開發大賽 (有很好的源码)
    GIT和repo使用方法:下载内核 android源码包
    Real6410系列教程 android
    [转]Protel布局文件转化为Allegro placement文件
    ubuntu网卡设置
    ubuntu 下安装java6的源
  • 原文地址:https://www.cnblogs.com/Chinarain/p/3821899.html
Copyright © 2011-2022 走看看