[Insight-users] Problem with itk-vtk in MFC
Wang Minyou
zjjywmy at hotmail.com
Thu Nov 24 12:25:35 EST 2005
Hi everyone,
I'm a freshman using itk. I have some problem with itk-vtk in MFC. I wrote
a Win32 Project in VC6. I want to use itk to readin a pic and view it with
vtk. Here is a portion of codes.
*********************************
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 );
typedef itk::ImageToVTKImageFilter<ImageType2D> ConnectorType2D;
ConnectorType2D::Pointer connector=ConnectorType2D::New();
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();
**************************
There is no problem when compiling and linking, but when running it results
in a "Runtime Error". Using Debug, I found it occurs when running
"viewer->Render();".
Does anyone can give some informations about where the wrong lie. Thank you
in advance!
_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn
More information about the Insight-users
mailing list