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;
  • 相关阅读:
    父组件和子组件之间的生命周期执行顺序
    Vue生命周期四个阶段
    Vue watch监听
    Vue computed计算属性 理解
    Vue中v-if 与 v-show的区别
    虚拟DOM
    MVC与MVVM原理
    单例模式 回流与重绘
    判断某个对象属于哪种数据类型
    原生JS的兼容性问题
  • 原文地址:https://www.cnblogs.com/aipeli/p/251775.html
Copyright © 2011-2022 走看看