<DIV> </DIV>
<DIV> </DIV>
<DIV>Hi,</DIV>
<DIV> </DIV>
<DIV>Thanks for your warmly help. But it seems not because of the filename's slashes. When i change the filename as the method your proposed, the exception was thrown out as before. And further more, i succeed in displaying image in Win32 console application, using both '\' and '/'. So i think the bug lies somewhere esle.</DIV>
<DIV>Thanks again and i'll appreciate your further help!</DIV>
<DIV> </DIV>
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #a0c6e5 2px solid; MARGIN-RIGHT: 0px">
<HR color=#a0c6e5 SIZE=1>
<BR>-----原始邮件-----<BR>发件人:"Karthik Krishnan" <KARTHIK.KRISHNAN@KITWARE.COM><BR>发送时间:2006-05-10 23:11:42<BR>收件人:"Alexander.Wang" <ZJJYWMY@163.COM><BR>抄送:insight-users@itk.org<BR>主题:Re: [Insight-users] Display image with ITK+VTK in SDI Applica tion<BR><BR><BR><PRE style="WIDTH: 100%; WORD-WRAP: break-word">On Wed, 2006-05-10 at 22:07 +0800, Alexander.Wang wrote:
> 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 exception in ***.exe (KERNEL32.DLL):
> 0xE06D7363: Microsoft C++ Exception". Does anybody could give me some
> help? Thanks in advance.
>
> Sincerely, Alexander
> 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 );
>
I suspect the filename's slashes are getting escaped. It should end up
looking like c:/foo/foo.png or like "c:\\foo\\foo.png" You could use
itksys to convert these paths from the native windows style paths.
#include "itksys/SystemTools.hxx"
std::string fname = strFile
itksys::SystemTools::ConvertToUnixSlashes(fname);
if (!itksys::SystemTools::FileExists(fname.c_str()))
{
std::cerr << fname << " doesn't exist.. check again" << std::endl;
}
> //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
>
>
>
>
>
>
>
>
>
> 你 不 想 试 试 今 夏 最 “酷” 的 邮 箱 吗 ?
> 蕴 涵 中 华 传 统 文 化 于 世 界 一 流 科 技 之 中,创 新 Ajax 技 术,
> 126 “D 计 划”火 热 体 验 中 !
> _______________________________________________
> Insight-users mailing list
> Insight-users@itk.org
> <A href="http://www.itk.org/mailman/listinfo/insight-users" target=_new>http://www.itk.org/mailman/listinfo/insight-users</A>
</PRE><!-- CoreMail Version 2.5 Copyright (c) 2002-2006 www.mailtech.cn --></BLOCKQUOTE><br><!-- footer --><br><br><br><br><br><div style="border-bottom:1px solid #999"></div><br>
        <font color="black" style="font-size:14.8px">你 不 想 试 试 今 夏 最 “酷” 的 邮 箱 吗 ?</font>
        <br>
         <a href="http://www.126.com/" target="_blank" style="font-size:13px;line-height:160%;color:blue">蕴 涵 中 华 传 统 文 化 于 世 界 一 流 科 技 之 中,创 新 Ajax 技 术,126 “D 计 划”火 热 体 验 中 !
</a>