| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2081 人关注过本帖
标题:我不能把验证码写入图片中。。怎么办!
取消只看楼主 加入收藏
小瘪三的烦恼
Rank: 1
等 级:新手上路
帖 子:86
专家分:3
注 册:2008-9-20
收藏
 问题点数:0 回复次数:2 
我不能把验证码写入图片中。。怎么办!
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Drawing.Imaging;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string str = suiji(4);
        Bitmap bit = new Bitmap(50, 20);
        Graphics g = Graphics.FromImage(bit);
        Font text = new Font("宋体",20);
        Rectangle rec = new Rectangle(0,0,50,20);
        g.FillRectangle(new SolidBrush(Color.Green), rec);      
        g.DrawString(str, text, new SolidBrush(Color.Blue),rec);
        bit.Save("yanzhen.jpg",ImageFormat.Jpeg);
        Image1.ImageUrl = "yanzhen.jpg";
    }
    public string suiji(int a)
    {
        string result = "";
        string str = "0,1,2,3,4,5,6,7,8,9";
        string[] arry = str.Split(',');
        Random ram = new Random();
        
        for (int i = 0; i < a; i++)
        {
            int k = ram.Next(10);
            result = result + arry[k];
        }
        return result;
    }
}

不能显示!

1.JPG (5.29 KB)
图片附件: 游客没有浏览图片的权限,请 登录注册
搜索更多相关主题的帖子: 验证 
2008-10-07 20:53
小瘪三的烦恼
Rank: 1
等 级:新手上路
帖 子:86
专家分:3
注 册:2008-9-20
收藏
得分:0 
呵呵 成功了!
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Drawing.Imaging;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string str = suiji(4);
        Bitmap bit = new Bitmap(50, 20);
        Graphics g = Graphics.FromImage(bit);
        Font text = new Font("宋体", 12);
        Rectangle rec = new Rectangle(0, 0, 50, 20);
        g.FillRectangle(new SolidBrush(Color.Green), rec);
        g.DrawString(str, text, new SolidBrush(Color.Blue), rec);
        bit.Save(Server.MapPath("yanzhen.jpg") , ImageFormat.Jpeg);
        Image1.ImageUrl = "yanzhen.jpg";
    }
    public string suiji(int a)
    {
        string result = "";
        string str = "0,1,2,3,4,5,6,7,8,9";
        string[] arry = str.Split(',');
        Random ram = new Random();

        for (int i = 0; i < a; i++)
        {
            int k = ram.Next(10);
            result = result + arry[k];
        }
        return result;
    }
}
2008-10-08 08:47
小瘪三的烦恼
Rank: 1
等 级:新手上路
帖 子:86
专家分:3
注 册:2008-9-20
收藏
得分:0 
恩。。。谢谢指教。。。我看看去。。我是新手。。
2008-10-10 09:24
快速回复:我不能把验证码写入图片中。。怎么办!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013659 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved