[Insight-users] Display image with ITK+VTK in SDI Applica tion

Alexander.Wang zjjywmy at 163.com
Wed May 10 10:07:16 EDT 2006


Hi users,
 
I recently started working on ITK, and I want to display images in windows using SDI Application. But there is some problem. When the Update() function of imagereader is executing, an exception is thrown out which says" Unhandles </SPAN><SPAN>exception in ***.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception". Does anybody could give me some help? Thanks in advance. 
 
Sincerely, Alexander
 
 
Some codes is as follows:
//Code begin
typedef itk::Image< int, 2 > ImageType2D;
typedef itk::ImageFileReader< ImageType2D > ImageReaderType2D;
typedef itk::ImageToVTKImageFilter<ImageType2D> ConnectorType2D;
ImageReaderType2D::Pointer imageReader2D_1 = ImageReaderType2D::New();
ImageReaderType2D::Pointer imageReader2D_2 = ImageReaderType2D::New();
ConnectorType2D::Pointer connector=ConnectorType2D::New();
CString strFile="";
char szFilter[]="bmp文件(*.bmp)|*.bmp|All files(*.*)|*.*||";
CFileDialog dlg(TRUE,"bmp",NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,szFilter,this);
dlg.m_ofn.lpstrInitialDir=".";
if(dlg.DoModal()==IDOK)
{
 strFile=dlg.GetPathName();
}
imageReader2D_1->SetFileName( strFile );
//Exception thrown out when executing this expression
imageReader2D_1->Update();
vtkImageViewer* viewer=vtkImageViewer::New();
vtkRenderWindowInteractor* ImgRenderWindowInteractor=vtkRenderWindowInteractor::New();
connector->SetInput(imageReader2D_1->GetOutput());
 
HWND hwnd = this->GetSafeHwnd();
viewer->SetParentId(hwnd);
viewer->SetPosition(0,0);
viewer->SetSize(512,512);
viewer->SetupInteractor(ImgRenderWindowInteractor);
 
viewer->SetInput(connector->GetOutput());
viewer->Render();
viewer->SetColorWindow(255);
viewer->SetColorLevel(128);
ImgRenderWindowInteractor->Start();
//Code End
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20060510/11d6de6b/attachment.htm


More information about the Insight-users mailing list