zoukankan      html  css  js  c++  java
  • 绘制不同颜色的文本图片

            private Bitmap strToImage(string str)
            {
                Font f = new Font(new FontFamily("宋体"), 10, FontStyle.Regular);
                float fontSizeWidth = 96 / (72 / f.Size); // 字体实际像素宽度   
                float fontSizeHeight = 96 / (72 / f.Size); // 字体实际像素高度   
               
    
                //创建此大小的图片
                Bitmap bmp = new Bitmap(str.Length * (int)(fontSizeWidth), 22);
                Graphics g = Graphics.FromImage(bmp);
                int fIndex= str.IndexOf(findText);
                string startStr = str.Substring(0, fIndex);
              
                float y= (23- (int)fontSizeHeight) / 2;
                g.DrawString(startStr, f, new SolidBrush(System.Drawing.Color.Black), new PointF(fontSizeWidth / 2,y));
                float startLenth = startStr.Length * (int)(fontSizeWidth );
                g.DrawString(findText, f, new SolidBrush(System.Drawing.Color.Red), new PointF(startLenth, y));//绘制红字
                string enStr = str.Substring(fIndex + findText.Length);
                float findTxLenth = findText.Length * (int)(fontSizeWidth );
                g.DrawString(enStr, f, new SolidBrush(System.Drawing.Color.Black), new PointF(startLenth+findTxLenth , y));
                g.Save();
                g.Dispose();
                return bmp;
            }
    
  • 相关阅读:
    跨媒体安全
    kali视频(21-25)学习
    kali视频(26-30)学习
    kali视频(16-20)学习
    kali视频学习(11-15)
    kali视频(1-5)
    使用Metaspoit攻击MS08-067
    web应用程序安全攻防---sql注入和xss跨站脚本攻击
    -区块链-
    TCP/IP网络协议攻击
  • 原文地址:https://www.cnblogs.com/bile/p/3173126.html
Copyright © 2011-2022 走看看