Commit 916cf198 authored by Joachim Pouderoux's avatar Joachim Pouderoux Committed by Kitware Robot

Merge topic 'FixWindowToImageFilterWithViewport'

88376dfb Fix crash of the WindowToImageFilter when specifying a Viewport.
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !919
parents c358a6a8 88376dfb
Pipeline #2790 running with stage
......@@ -74,6 +74,7 @@ vtk_add_test_cxx(${vtk-module}CxxTests tests
TestTStripsNormalsColorsTCoords.cxx
TestTStripsNormalsTCoords.cxx
TestTStripsTCoords.cxx
TestWindowToImageFilter.cxx
otherLookupTable.cxx,NO_VALID
otherLookupTableWithEnabling.cxx,NO_VALID
RenderNonFinite.cxx
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestWindowToImageFilter.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkTestUtilities.h"
#include "vtkRegressionTestImage.h"
#include "vtkActor.h"
#include "vtkImageActor.h"
#include "vtkImageMapper3D.h"
#include "vtkNew.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkSphereSource.h"
#include "vtkWindowToImageFilter.h"
int TestWindowToImageFilter(int argc, char* argv[])
{
vtkNew<vtkSphereSource> sphereSource;
sphereSource->SetCenter(0.0, 0.0, 0.0);
sphereSource->SetRadius(5.0);
sphereSource->Update();
// Render the sphere
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputConnection(sphereSource->GetOutputPort());
vtkNew<vtkActor> actor;
actor->SetMapper(mapper.Get());
vtkNew<vtkRenderer> renderer;
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->AddRenderer(renderer.Get());
renderWindow->SetMultiSamples(0);
vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
renderWindowInteractor->SetRenderWindow(renderWindow.Get());
renderer->AddActor(actor.Get());
renderWindow->Render();
// Take the partial screenshot
vtkNew<vtkWindowToImageFilter> windowToImageFilter;
windowToImageFilter->SetInput(renderWindow.Get());
windowToImageFilter->SetInputBufferTypeToRGB();
windowToImageFilter->SetViewport(0.5, 0.5, 0.8, 1.0);
windowToImageFilter->ReadFrontBufferOff(); // read from the back buffer
windowToImageFilter->Update();
// Show the screenshot
vtkNew<vtkImageActor> imageActor;
imageActor->GetMapper()->SetInputData(windowToImageFilter->GetOutput());
renderer->RemoveActor(actor.Get());
renderer->AddActor(imageActor.Get());
renderWindow->Render();
renderer->ResetCamera();
renderWindow->Render();
int retVal = vtkRegressionTestImage(renderWindow.Get());
if (retVal == vtkRegressionTester::DO_INTERACTOR)
{
renderWindowInteractor->Start();
}
return !retVal;
}
This diff is collapsed.
......@@ -108,7 +108,8 @@ public:
// Description:
// Set/get the extents to be used to generate the image. Initial value is
// {0,0,1,1} (This option does not work if Magnification > 1.)
vtkSetVector4Macro(Viewport,double);
void SetViewport(double, double, double, double);
void SetViewport(double*);
vtkGetVectorMacro(Viewport,double,4);
// Description:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment