???????????
Dim cc(10) As Byte
        Dim aa As System.Drawing.Image
        Dim bb As System.IO.Stream
        bb.Write(cc, 0, 10)
        aa.FromStream(bb)

解决方案 »

  1.   

    here is an example, also seehttp://msdn.microsoft.com/msdnmag/issues/02/02/aspdraw/default.aspx
    <%@ Import Namespace="System.Drawing" %>
    <%@ Import Namespace="System.Drawing.Imaging" %>
    <%@ Import Namespace="System.Drawing.Drawing2D" %>
    <script runat="server" language="C#">
    void Page_Load(object o, EventArgs e)
    {
    double angle = 225;
    int nWidth = 400, nHeight = 400;
    Bitmap objBitmap = new Bitmap(nWidth, nHeight);
    Graphics g = Graphics.FromImage(objBitmap);
    g.SmoothingMode = SmoothingMode.AntiAlias;



    //g.FillRectangle(Brushes.White,this.ClientRectangle);
    Font f = new Font("Times New Roman", 14,System.Drawing.FontStyle.Bold);

    g.TranslateTransform(nWidth /2,nHeight/2);
    g.FillEllipse(Brushes.Black,nHeight/-2,nHeight/-2,nHeight, nHeight);

    g.DrawString("MPH",f,Brushes.Green,-26,nHeight/-4);


    //g.TranslateTransform(nWidth /2,nHeight/2);
    g.RotateTransform(225);
    for(int x = 0; x<55;x++)
    {
    g.FillRectangle(Brushes.Green,-2,(nHeight/2 -2)* -1,3,15);
    g.RotateTransform(5);
    }
    g.ResetTransform(); g.TranslateTransform(nWidth /2,nHeight/2);
    g.RotateTransform(225);
    int sp = 0;
    for(int x = 0; x<7;x++)
    {
    g.FillRectangle(Brushes.Red,-3,(nHeight/2 -2)* -1,6,25);
    g.DrawString(sp.ToString(),f,Brushes.Azure,(sp.ToString().Length)*(-6),(nHeight/-2) + 25);
    g.RotateTransform(45);
    sp += 20;
    }
    g.ResetTransform();

    g.TranslateTransform(nWidth /2,nHeight/2); g.RotateTransform((float)angle);
    Pen P = new Pen(System.Drawing.SystemColors.Desktop,14);
    P.EndCap = LineCap.ArrowAnchor;
    P.StartCap = LineCap.RoundAnchor;
    g.DrawLine(P,0,0,0,(-1)*(nHeight/2.75F));
    //P.Width = 16;
    //g.DrawLine(P,0,0,0,(-1)*(nHeight/2.75F));
    g.ResetTransform();

    g.TranslateTransform(nWidth /2,nHeight/2); g.FillEllipse(Brushes.Black,-6,-9,14,14);
    g.FillEllipse(Brushes.Red,-7,-7,14,14); P.Width = 4;
    P.Color = Color.Black;
    P.EndCap = LineCap.Round;
    P.StartCap = LineCap.Flat;
    g.DrawLine(P,nHeight/15.75F,nHeight/3.95F,nHeight/10.75F,nHeight/5.2F);

    P.Color = Color.Red;
    g.DrawLine(P,nHeight/15.75F,nHeight/3.95F,nHeight/15.75F,nHeight/4.6F); P.Dispose();
    objBitmap.Save(Response.OutputStream, ImageFormat.Gif); objBitmap.Dispose();
    g.Dispose();}
    </script>
      

  2.   

    这是我写的一个函数,已经调试成功,显示在网页中只需要"<img src=" & picPath & ">"就可以了
    /// <summary>
    /// 将指定的字符串转换为指定路径的图片(字符串由Byte类型的数据组成,每个Byte由";"格开)
    /// </summary>
    /// <param name="str">字符串数据</param>
    /// <param name="picPath">生成的图片路径</param>
    public static void ConvertStringToPic(string ImageContent,string picPath)
    {
    string[] strImg=ImageContent.Split(';');
    byte[] picbyte=new Byte[strImg.Length];
    for(int i=0;i<strImg.Length-1;i++)
    {
    picbyte[i]=Convert.ToByte(strImg[i]);
    }
    try
    {

    if (System.IO.File.Exists(picPath)) 
    {
    System.IO.File.Delete(picPath);
    }
    System.IO.FileStream FS=new System.IO.FileStream(picPath,System.IO.FileMode.Create);
    FS.Write(picbyte,0,strImg.Length);
    FS.Close();
    }
    catch
    {}
    }
      

  3.   

    a.aspx?str=hello
    参数是什么, 就出什么字的图片<%@Page language="c#" contenttype="image/jpeg" %>
    <%@import namespace="System.Drawing"%>
    <%@import namespace="System.Drawing.Imaging"%>
    <%@import namespace="System.Drawing.Drawing2D"%>
    <%
    String str = Request.Params["str"];
    if(str == ""||str == null)
    str = "请输入参数str";
    Response.Clear();
    Bitmap img = new Bitmap(240, 30, PixelFormat.Format24bppRgb);
    Graphics g = Graphics.FromImage(img);
    g.Clear(Color.Green);
    g.SmoothingMode = SmoothingMode.AntiAlias;
    g.DrawString(str, new Font("黑体", 16, FontStyle.Bold), new SolidBrush(Color.White), new Point(1,1));
    g.FillRectangle(new LinearGradientBrush(new Point(0,0), new Point(240, 30), Color.FromArgb(0,0,0,0), Color.FromArgb(255,255,255,255)), 0,0,240,30);
    img.Save(Response.OutputStream, ImageFormat.Jpeg);
    g.Dispose();
    img.Dispose();
    Response.End();
    %>