MFC & vtkWriter problem

pahsieh at pahsieh at
Sat Jan 22 00:08:45 EST 2000


> 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();

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()

  vtkWindowToImageFilter* renSrc = vtkWindowToImageFilter::New();

  vtkBMPWriter* writer = vtkBMPWriter::New();


  // Insert the next line to return to screen rendering

This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.

More information about the vtkusers mailing list