我在DLG中使用VTK 导入一个BMP图片的程序实验中发现,当BMP和DLG中用来显示图片的静态文本框大小不一致时,图片显示不完整(超出部分显示不出来)。为了解决问题我就想到了,放缩的方式,但是这种方法我发现很麻烦。有没有其他简单的方法,使整副图片窗缩放到静态文本框内。
   下面这两个主要函数第一个是用来读取图片的路径,第二函数是将vtk和静态文本句柄绑定。
具体代码如下:

         void CVTK::BmpRead(CString fileName)
{
bmpReader->SetFileName(fileName);
bmpReader->Update();
bmpMagify->SetInputConnection(bmpReader->GetOutputPort()); 

    bmpViewer->SetInput(bmpMagify->GetOutput());
bmpViewer->SetupInteractor(iren);
bmpViewer->SetColorWindow(256); 
bmpViewer->SetColorLevel(200); 
bmpViewer->SetPosition(0,0);
}void CVTK:: BeginRenderOn2(CStatic* aStatic)
 {
 CRect rect;
 aStatic->GetClientRect(&rect);
 //int *temp1;
// temp1=bmpViewer->GetRenderWindow()->GetSize();
 
 //bmpMagify->SetMagnificationFactors(1,1,1);
 bmpViewer->SetSize(rect.Width(),rect.Height());
 bmpViewer->SetParentId(aStatic->m_hWnd);
 bmpViewer->Render();
 }