zoukankan      html  css  js  c++  java
  • 产生随机图片,并返回图片内的文字

    /// <summary>
            
    /// 产生随机图片,并返回图片内的文字
            
    /// </summary>
            
    /// <param name="img">要显示图片的控件</param>        
            
    /// <param name="path">图片显示的文字</param>

            public string R_random(System.Web.UI.WebControls.Image img,string path)
            
    {                
                
    string tmp;//文字
                Random rnd=new Random();
                tmp
    =rnd.Next().ToString().Substring(0,4);
                Graphics g
    =null;
                Bitmap bmp
    =new Bitmap(50,100);
                g
    =Graphics.FromImage(bmp);
                SizeF rec
    =g.MeasureString(tmp,new Font("宋体",12));
                
    int nwidth=(int)rec.Width;
                
    int nheight=(int)rec.Height;
                g.Dispose();
                bmp.Dispose();
                bmp
    =new Bitmap(nwidth,nheight);
                g
    =Graphics.FromImage(bmp);
                g.FillRectangle(
    new SolidBrush(Color.FromArgb(90126220)), new Rectangle(0,0,nwidth,nheight));
                g.DrawString(tmp,
    new Font("宋体",12), new SolidBrush(Color.Yellow), new PointF(00));
                
    string fff=path+ @"tmp\validation.gif";
                bmp.Save(fff,System.Drawing.Imaging.ImageFormat.Gif);                
                img.ImageUrl
    =fff;
                
    return tmp;
  • 相关阅读:
    HDU 5120 计算两圆环相交面积
    HDU
    Dinic (邻接表实现) + 当前弧优化
    java —— static 关键字
    java —— this 关键字
    双连通分量 Road Construction POJ
    2-SAT(HDU-3062 party)
    java——构造器理解
    『题解』Codeforces1142A The Beatles
    『题解』Codeforces1142B Lynyrd Skynyrd
  • 原文地址:https://www.cnblogs.com/aipeli/p/251775.html
Copyright © 2011-2022 走看看