byteまたはStreamを画像に変換


 <img src="/QRCode/index" alt=" " style="width:150px; height:150px;" />
 public ActionResult Index()
        {
            Stream stream = null;
            byte[] byteData = null;
            string userId = Convert.ToString(System.Web.HttpContext.Current.Session["yuan_userid"]);
            var userModel = ServiceLocator.Create<EnYuan.BSS.User.IUserService>().GetUser(userId);
            string userName = "";
            if (userModel != null)
                userName = userModel.Name;
            try
            {
                var model = QRCodeImgDao.Instance.GetModel(userId);
                if (model == null)
                {
                    // 
                    QRCodeImgModel QRmodel = new QRCodeImgModel();
                    QRmodel.UserId = userId;
                    // 
                    QRmodel.QudaoId = QRCodeImgDao.Instance.AutoAddId();
                    #region  
                    string UrlImg = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + QRCode_WxHelper.CreateQRCode(QRmodel.QudaoId);
                    WebClient webClient = new WebClient();
                    webClient.Credentials = CredentialCache.DefaultCredentials;
                    // 
                     byteData = webClient.DownloadData(UrlImg);
                    //stream = BytesToStream(byteData);
                    #endregion
                   
                }
                 else
                { 
                    if (!string.IsNullOrEmpty(model.QRCodeImg))
                    {
                        byteData = System.Convert.FromBase64String(model.QRCodeImg); 
                    } 
                }
                
            }
            catch { }
            return File(byteData, "image/jpeg");  
        }