Hello,
After getting distracted from my dicom projects, I am now picking it up again. I am tinkering with simply making a program that opens a DICOM file fromt he filesystem and displays it. Essentially, just a "Hello World" application of DICOM display - no selecting the file, etc etc.
I am having a problem with a DicomException being thrown in the following code:
private void Form1_Load(object sender, EventArgs e)
{
DicomEngine.Startup();
//open file
string file = "C:\\dcm\\test.dcm";
DicomDataSet ds = new DicomDataSet(file);
//get image, and set it as the displayed image
//theViewer is a RasterImageViewer WinForm control
RasterImage image;
image = ds.GetImage(null, 0, 0, RasterByteOrder.Gray, DicomGetImageFlags.None);
theViewer.Image = image;
DicomEngine.Shutdown();
}
I get a DicomException for the GetImage call. Here is the Stack Trace:
at Leadtools.Dicom.DicomException.CheckErrorCode(Int32 code)
at Leadtools.Dicom.DicomDataSet.GetImage(DicomElement element, Int32 index, Int32 bitsPerPixel, RasterByteOrder order, DicomGetImageFlags flags)
at TestDisplay.Form1.Form1_Load(Object sender, EventArgs e) in C:\Documents and Settings\Will\Local Settings\Application Data\Temporary Projects\TestDisplay\Form1.cs:line 33
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at TestDisplay.Program.Main() in C:\Documents and Settings\Will\Local Settings\Application Data\Temporary Projects\TestDisplay\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Any thoughts, ideas, etc? Am I doing something obviously wrong? FYI, the DICOM file is valid, displays in any DICOM viewer, and is readable on the file system.
Thank you,
Will