MFC & vtkWriter problem

Agris Klimkans agris at phc.chalmers.se
Sat Jan 22 12:37:08 EST 2000


Hello!

Great!
It really works, even on my P200 :-)
Such knowledge should be included in the user's guide, I think!


Thanks a lot for help!
Sincerely,
-------------------------------------------
Agris Klimkans
Dept. of Physical Chemistry, office 5020
Chalmers University of Technology
S-41296 Gothenburg
Sweden

 phone: (+46)31-7723051
   fax: (+46)31-7723858
mailto:agris at phc.chalmers.se
-------------------------------------------



----- Original Message ----- 
From: <pahsieh at usgs.gov>
To: Agris Klimkans <agris at phc.chalmers.se>
Cc: <vtkusers at gsao.med.ge.com>
Sent: Saturday, January 22, 2000 6:08 AM
Subject: Re: MFC & vtkWriter problem


> 
> Agris:
> 
> > There is a little problem in a 'combination' of the 'vtkWriter' and the
> MFC 'CFileDialog'.
> > My MDI program renders to a 'CView' derived window and everything is fine
> until I want to
> > save the rendered image in a file, using a 'vtkWriter' derived class
> (like 'vtkBMPWriter').
> > The 'CFileDialog' window is hiding a part of the rendered image. In
> saving the image using the
> > 'vtkBMPWriter', it saves also a part of the dialog box, which was above
> the image.
> 
> When you do
> 
>   vtkWindowToImageFilter* renSrc = vtkWindowToImageFilter::New();
>    renSrc->SetInput(m_pRenderer->GetVTKWindow());
> 
> you capture the vtk window on the screen, including whatever is
> covering parts of the window (for example, your file dialog box,
> other modeless dialog boxes, or a help window that is
> always on top).
> 
> The workaround is to render to memory, and write the bitmap
> with the data from memory, something like the following:
> 
> 
>  if( dlg.DoModal() == IDOK)
>  {
>   sFileName = dlg.GetPathName();
> 
>   // Insert the next 3 lines to render to memory, assuming your render
> window is
>   // called m_pRenderWindow, and is of type vtkWin32OpenGLRenderWindow.
>   int *size = m_pRenderWindow->GetSize();
>   m_pRenderWindow->SetupMemoryRendering(size[0], size[1], GetDC()
> ->GetSafeHdc());
>   m_pRenderWindow->Render();
> 
>   vtkWindowToImageFilter* renSrc = vtkWindowToImageFilter::New();
>    renSrc->SetInput(m_pRenderer->GetVTKWindow());
> 
>   vtkBMPWriter* writer = vtkBMPWriter::New();
>    writer->SetInput(renSrc->GetOutput());
>    writer->SetFileName(sFileName.GetBuffer(10));
>    writer->Write();
> 
>   renSrc->Delete();
>   writer->Delete();
> 
>   // Insert the next line to return to screen rendering
>   m_pRenderWindow->ResumeScreenRendering();
>  }
> 
> 
> 
> 
> 
> 
> -----------------------------------------------------------------------------
> This is the private VTK discussion list.  Please keep messages on-topic.
> Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
> To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
> <majordomo at gsao.med.ge.com>.  For help, send message body containing
> "info vtkusers" to the same address.     Live long and prosper.
> -----------------------------------------------------------------------------



-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------




More information about the vtkusers mailing list