在视图中绘制图像(Rendering image in a View)

2019-10-29 04:14发布

我想表现出一个强类型查看一些图片的用户。在模型成员有一个表示图像的内容(例如,JPEG),我应该怎样度过这个内容IMG标签来渲染这个形象? 模型是这样的:

publiс class Image {
public virtual FileContentResult currentImage { get; set; }
public Image()
        {
            currentImage = createSomeImage(); 
// createSomeImage returns new FileContentResult(bmpBytes, "image/png");
        }
}

查看样子

@model app.Models.Image
<img src='@Model.currentImage' alt="" class="img" />

我从父视图为使其:

@Html.Partial("_ImageShow", new app.Models.Image())

我搜索了很多,但只找到返回的图像作为一些controller..Is有什么办法可以显示在视图中有fileContentResult形象的行动结果的实现? 提前致谢。

文章来源: Rendering image in a View