简体   繁体   中英

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

My application is asp.net MVC3; currently I can display DCIOM MPR images using image handler and storing the image in the session using:

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:

............
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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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