简体   繁体   English

在ASP.NET MVC视图中显示DICOM MPR图像C#

[英]Displaying DICOM MPR image in asp.net MVC view c#

My application is asp.net MVC3; 我的应用程序是asp.net MVC3; currently I can display DCIOM MPR images using image handler and storing the image in the session using: 当前,我可以使用图像处理程序显示DCIOM MPR图像,并使用以下方式将图像存储在会话中:

objImage = im.Bitmap(outputSize, System.Drawing.Imaging.PixelFormat.Format24bppRgb, m);
context.Response.ContentType = "image/png";
objImage.Save(context.Response.OutputStream,     
System.Drawing.Imaging.ImageFormat.Png);

It works fine, however when I rotate the image the response is very slow!! 它工作正常,但是当我旋转图像时,响应非常慢! I am trying to store the DICOM MPR in the controlloer as a session variable using the following: 我正在尝试使用以下命令将DICOM MPR作为会话变量存储在controlloer中:

............
DicomImageMPR mpr1 = new DicomImageMPR(volume);
mpr1.SetViewPlane(new Point3D(), new Vector3D(0, 1, 0), new Vector3D(0, 0, -1));
mpr1.Interpolation = InterpolationType3D.Trilinear;
MySession.Current.mpr1 = mpr1;

My question is how I can put the image in a viewbag to display in the view? 我的问题是如何将图像放入视图包中以在视图中显示? I would appreciate your suggestions, and thanks in advance. 非常感谢您的建议,并在此先感谢。

I solved it by using the following: 我通过使用以下方法解决了它:

       public ActionResult GenerateImage()
            {
                FileContentResult result;
                System.Drawing.Image objImage = null;
              ....
                mpr = MySession.Current.mpr2;
                im = mpr;
               ...
                objImage = im.Bitmap(outputSize,  
                System.Drawing.Imaging.PixelFormat.Format24bppRgb, m);
                using (var memStream = new MemoryStream())
                {
                    objImage.Save(memStream, System.Drawing.Imaging.ImageFormat.Png);
                    result = this.File(memStream.GetBuffer(), "image/png");
                }

                return result;
            }

In the View: 在视图中:

<img src='<%=Url.Action("GenerateImage")%>' alt="" id="dImage"/>

Hope this could help someone. 希望这可以帮助某人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM