渲染图像时出现问题

时间:2019-12-17 14:39:02

标签: c# image render

我需要保存图像并在下次访问时进行渲染。

我使用以下方法:

读取图像并将其存储在字符串中:

 public void UpdateProfileImage(Stream profileImageAsStream, string fileExtension)
        {
                    StreamReader reader = new StreamReader(profileImageAsStream);
                    string Icon = reader.ReadToEnd();
                    string portrait = fileExtension;
         }

在渲染时,我将图像保存到文件系统并返回图像的相对URL。

   private string ImageURLFromMemoryStream(string icon, string portrait)
        {

                string fileId = Guid.NewGuid().ToString().Replace("-", "");
                fileId = fileId + "." + portrait;
                var path = Path.Combine(HttpContext.Current.Server.MapPath("~/Uploads/Photo/"), fileId);

                using (var file = File.Create(path))
                {
                    ConvertStringToStream(icon).WriteTo(file);
                }
                var rootPath = HttpContext.Current.Server.MapPath("/");
                return path.TrimStart(rootPath.ToCharArray());

        }

我面临的问题是图像无法渲染,当我尝试在新标签页中浏览图像时,出现错误the image cannot be displayed because it contains errors

知道我在做什么错吗?

0 个答案:

没有答案