MFC & vtkWriter problem
pahsieh at usgs.gov
pahsieh at usgs.gov
Sat Jan 22 00:08:45 EST 2000
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.
-----------------------------------------------------------------------------
More information about the vtkusers
mailing list