我有一个xml 文件 经过转换成byte[]后 怎么显示在img 中 跟picbox 似的 
winform 中 可用picbox 如下 
byte[] bytImg = Convert.FromBase64String(strResult.Substring(2));
MemoryStream imgStream = new MemoryStream(bytImg);
Bitmap img = new Bitmap(imgStream);
picbox.Image = img;但是 web 中怎么处理啊 

解决方案 »

  1.   

    你可以单独用一个页面来处理,比如a.aspx,在a.aspx的onload里面写如这些代码,不过不需要后面两句,你只需要保存在memorystream,然后以位图的形式输出就可以了,然后在页面的图片src = "a.aspx"就行了,验证码就是这样做的。
      

  2.   

    我怎么有点晕,在image中显示xml? 
      

  3.   

    新建个一般处理程序 ashxbyte[] imgData = null;
    //加载xml
                        Response.ContentType = "image/jpeg";
                        Response.BinaryWrite(imgData);
                        Response.End();
                        return;
                   
      

  4.   

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;namespace WebApp.handler {
        /// <summary>
        /// $codebehindclassname$ 的摘要说明
        /// </summary>
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        public class ShowImgHandler : IHttpHandler {        public void ProcessRequest(HttpContext context) {
                string strResult = "";
                byte[] bytImg = Convert.FromBase64String(strResult.Substring(2));
                context.Response.ContentType = "image/jpeg";
                context.Response.BinaryWrite(bytImg);
                context.Response.End();
            }        public bool IsReusable {
                get {
                    return false;
                }
            }
        }
    }
      

  5.   

    我有一个com组件的dll 这个dll 中有把xml 文件转换成img 的接口 通过一个fileupload xml文件 上传显示为image 
      

  6.   

    调用DLL相关函数
    Response.ContentType = "image/JPEG";   
    Response.BinaryWrite((Byte[])reader["Photo"]);   
    Response.End();