Question

There was individual, whom post a code to load and display a DICOM image in C# with the ClearCanvas Library. However, I tried t run the code and i'm receiving an error and have a missing library dll component. I would like to know where the individual obtained the library dll file ClearCanvas.Dicom.ImageViewwer.StudyManagement. I've been unable to locate that file on the internet. The code is displayed after the errors. I am grateful thanks.

Usings:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ClearCanvas.Common;
using ClearCanvas.Dicom;
using System.Windows.Media.Imaging;
using ClearCanvas.ImageViewer;
using ClearCanvas.ImageViewer.StudyManagement;
using System.Windows.Interop;
using System.Windows.Media;

This is the body:

        OpenFileDialog ofd = new OpenFileDialog();
        ofd.Filter = "DICOM Files(*.*)|*.*";
        if (ofd.ShowDialog() == DialogResult.OK)
        {
            if (ofd.FileName.Length > 0)
            {

                var imagen = new DicomFile(ofd.FileName);

                LocalSopDataSource DatosImagen = new LocalSopDataSource(ofd.FileName);

                ImageSop imageSop = new ImageSop(DatosImagen);

                IPresentationImage imagen_a_mostrar = PresentationImageFactory.Create(imageSop.Frames[1]);

                int width = imageSop.Frames[1].Columns;

                int height = imageSop.Frames[1].Rows;

                Bitmap bmp = imagen_a_mostrar.DrawToBitmap(pictureBox1.Width, pictureBox1.Height);

                pictureBox1.Image = bmp;

                imageOpened = true;

            }
            ofd.Dispose();
        }
    }
Was it helpful?

Solution

In addition to referencing the proper assemblies (here... it's linked from the main page of clearcanvas.ca) I mentioned in a comment, consider employing the using keyword since OpenFileDialog implements IDisposable like so:

using(OpenFileDialog ofd = new OpenFileDialog())
{
   ofd.Filter = "DICOM Files(*.*)|*.*";
   if (ofd.ShowDialog() == DialogResult.OK)
   {
      // rest of your code goes here
   }
}

This has the benefit of calling ofd.Dispose() automatically, even if the code inside the using block throws an exception. This works for anything that implements IDisposable (so bitmaps, fonts, streams, etc.)

OTHER TIPS

I posted the code actually..

These are the DLLs I used in my project:

Clearcanvas:

ClearCanvas.Common.dll
ClearCanvas.Desktop.dll
ClearCanvas.Dicom.dll
ClearCanvas.ImageViewer.Common.dll
ClearCanvas.ImageViewer.dll
ClearCanvas.Utilities.Manifest.dll

Others I also added since I was getting an error when trying to show the image..

log4net.dll
nunit.framework.dll
WindowsBase.dll
BilinearInterpolation.dll --> For this one make sure you add either the 32 or 64 bits dll depending on what's your project defaults.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top