【发布时间】:2019-09-06 21:54:17
【问题描述】:
所以,我从本地网络获取 .tiff 文件,其中许多文件具有多个层。我将每一层转换为一个新的图像对象,这似乎可以工作,但现在我无法在我的视图中显示每个图像。我不想以可以显示的格式保存这些新图像。我正在寻找一种方法来绘制对象或仅仅能够显示图片或缩略图。 任何建议,将不胜感激。
@foreach (var img in ViewBag.ImageData)
{
<h2>@img</h2>
}
这显示不正确。
控制器:
//Convert .tiff layers to Image and save in list
List<Image> images = new List<Image>();
Bitmap bitmap = (Bitmap)Image.FromFile("\path\190625141847.tif");
int count = bitmap.GetFrameCount(FrameDimension.Page);
for (int idx = 0; idx < count; idx++)
{
// save each frame to a bytestream
bitmap.SelectActiveFrame(FrameDimension.Page, idx);
MemoryStream byteStream = new MemoryStream();
bitmap.Save(byteStream, ImageFormat.Tiff);
// and then create a new Image from it
images.Add(Image.FromStream(byteStream));
}
// Returned to view in ViewBag
ViewBag.ImageData = images;
我可能会将图像放入轮播等中,但我真的只是想在我的视图中显示每个图像(每一层)。
【问题讨论】:
-
“这显示不正确。” - 那它有什么作用呢?
-
它只是显示一个默认缩略图......就像您尝试显示 .tiff 图像本身一样。
标签: c# image model-view-controller tiff