数据库二进制流图片数据转换成图片

 public string GetDoctorInfoImage(ShowMzyyParam sp,string rootPath)
        {
            var datas = data.GetDoctorInfoImage(sp);
            byte[] image = (byte[])datas.photo;//二进制流(图片)
            var timeStamp = ConvertDateTimeToInt(DateTime.Parse(datas.LastTime.ToString()));
            string photoUrl = rootPath + "Content\\DoctorImgs\\" + datas.doctorName + timeStamp.ToString() + ".jpg";//生成的路径图片文件名
            FileStream fs = new FileStream(photoUrl, FileMode.OpenOrCreate, FileAccess.Write);
            BinaryWriter bw = new BinaryWriter(fs);
            bw.BaseStream.Write(image, 0, image.Length);
            bw.Flush();
            bw.Close();
            return photoUrl;
        }

注意下,这个转换,可能需要限制下图片数据的大小,因为查询图片的数据量过大,会导致,数据连接时间过长(读取图片数据),然后会报错

感谢:http://lib.csdn.net/article/csharp/39655

posted @ 2017-09-08 09:33  蜗牛的礼物  阅读(527)  评论(0编辑  收藏  举报