国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

ASP.net生成文字圖片

2019-11-18 19:28:59
字體:
供稿:網(wǎng)友

   string _FontName = Request["fontname"].ToString();
   int _FontSize = Convert.ToInt16(Request["fontsize"]);
   string _ShowName = Request["str"].ToString();
  
  
   Bitmap objBitmap = null;
   Graphics g = null ;
  
   Font stringFont = new Font(_FontName, _FontSize, FontStyle.Bold );
   StringFormat stringFormat = new StringFormat();
   stringFormat.FormatFlags = StringFormatFlags.NoWrap;


   try
   {
    objBitmap = new Bitmap(1,1);
    g = Graphics.FromImage(objBitmap);
    SizeF stringSize = g.MeasureString(_ShowName, stringFont);
    int nWidth = (int)stringSize.Width;
    int nHeight = (int)stringSize.Height;
    g.Dispose();
    objBitmap.Dispose();

    objBitmap = new Bitmap(nWidth,nHeight);
    g = Graphics.FromImage(objBitmap);
    g.FillRectangle(new SolidBrush(Color.Yellow), new Rectangle(0,0,nWidth,nHeight));
    g.TextRenderingHint = TextRenderingHint.AntiAlias;
    g.DrawString(_ShowName, stringFont, new SolidBrush(Color.Black), new PointF(0, 0), stringFormat);  
    objBitmap.Save(Response.OutputStream, ImageFormat.Gif);
   }
   catch (Exception ee)
   {
    Response.Write(ee.ToString());
   }
   finally
   {
    if (null != g) g.Dispose();
    if (null != objBitmap) objBitmap.Dispose();
    Response.End();
   }


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 昌平区| 彰化县| 仁布县| 宜兰县| 中阳县| 太原市| 司法| 团风县| 旌德县| 兴业县| 酉阳| 元氏县| 陇川县| 大埔区| 铜川市| 康马县| 公主岭市| 三门县| 万安县| 南开区| 乐清市| 德令哈市| 平阴县| 宁乡县| 鲁山县| 六枝特区| 天台县| 辽阳县| 乌海市| 榆林市| 防城港市| 聂荣县| 阆中市| 都江堰市| 丽江市| 乐山市| 上思县| 凉城县| 松原市| 松桃| 昌都县|