[vtkusers] vtkWindowToImageFilter
xabi riobe
xabivtk at gmail.com
Tue Jan 16 04:14:39 EST 2007
Hello zx,
you could try something using this piece of code:
vtkRenderWindow* pRenderWindow = pWindow->getRenderWindow();
vtkWindowToImageFilter* pWindowToImageFilter = vtkWindowToImageFilter::New();
vtkRenderWindow *renWin2 = vtkRenderWindow::New();
renWin2->OffScreenRenderingOn();
pWindowToImageFilter->SetInput(renWin2);
vtkBMPWriter* pBMPWriter = vtkBMPWriter::New();
pBMPWriter->SetInputConnection(pWindowToImageFilter->GetOutputPort());
pBMPWriter->SetFileName("C:\\ExportRenderWindow2BMP.jpg");
vtkRenderer *ren = pRenderWindow->GetRenderer();
double oldPScale = ren->GetActiveCamera()->GetParallelScale();
double newPScale = what you want;
ren->GetActiveCamera()->SetParallelScale(newPScale);
renWin2->AddRenderer(ren);
ren->SetRenderWindow(renWin2);
renWin2->SetSize(Width, Height);
ren->Modified();
renWin2->Modified();
renWin2->Render();
pWindowToImageFilter->Modified();
pWindowToImageFilter->Update();
pBMPWriter->Write();
renWin2->RemoveRenderer(ren);
ren->SetRenderWindow(pRenderWindow);
ren->GetActiveCamera()->SetParallelScale(oldPScale);
HTH,
Xabi.
2007/1/16, zx_sanjin at 163.com <zx_sanjin at 163.com>:
> hey all,
> I'm using the vtkWindowToImageFilter class for the screen shot to a image
> file. I used VS2005, vtk 4.1 under the windowXP.
>
>
>
> Here is my code:
>
>
>
> vtkRenderWindow* pRenderWindow = pWindow->getRenderWindow();
>
>
>
> vtkWindowToImageFilter* pWindowToImageFilter =
> vtkWindowToImageFilter::New();
>
> pWindowToImageFilter->SetInput(pRenderWindow);
>
> pWindowToImageFilter->Update();
>
>
>
> vtkBMPWriter* pBMPWriter = vtkBMPWriter::New();
>
> pBMPWriter->SetInputConnection(pWindowToImageFilter->GetOutputPort());
>
> pBMPWriter->SetFileName("C:\\ExportRenderWindow2BMP.jpg");
>
>
>
> pRenderWindow->Render();
>
> pWindowToImageFilter->Modified();
>
> pBMPWriter->Write();
>
>
>
> When the render image size smaller than the screen size, in the other words,
> when you can see the whole image in the screen, these code work fine;
>
> But, when the render image size bigger than the screen size, in the other
> words, after zoom in, when you can only see a part of the image, you can
> only get what you see, the saved image size is same to screen's size.
>
> I want to get the whole image data to image file, who can help me, thanks
> for any advice!
>
More information about the vtkusers
mailing list