[vtkusers] vtkWindowToImageFilter problem

Leguay Romain romain.leguay at etu.u-bordeaux1.fr
Thu Jun 16 05:01:41 EDT 2011


Hello everyone!
I want to do a screenshot of my scene. To do this I follow the example http://www.vtk.org/Wiki/VTK/Examples/Cxx/Utilities/Screenshot.
For information, I work on a java project.
My application closes itself without errors. 
I send you my code:

public void saveScreenshot(String fileName) {
	
		vtkWindowToImageFilter windowToImageFilter = new vtkWindowToImageFilter();
		windowToImageFilter.SetInput(fr.cea.visualization.renderer.Activator
				.getDefault().getRenderer().getPanel().GetRenderWindow());
		windowToImageFilter.SetMagnification(magnification); //pour augmenter la résolution
		windowToImageFilter.SetInputBufferTypeToRGBA(); //pour lire toutes les composantes couleurs
		
               windowToImageFilter.Update(); // <<<<----- when I launch the Update method, nothing appends and my application closes itself

		switch (type) {
		case JPEG:
			vtkJPEGWriter jpegWriter = new vtkJPEGWriter();
			jpegWriter.SetFileName(fileName);
			jpegWriter.SetInput(windowToImageFilter.GetOutput());
			jpegWriter.Write();
			break;
		case PNG:
			vtkPNGWriter pngWriter = new vtkPNGWriter();
			pngWriter.SetFileName(fileName);
			pngWriter.SetInput(windowToImageFilter.GetOutput());
			pngWriter.Write();
			break;
		default:
			return;
		}
	}

I don't understand why this code doesn't work.
Has anyone got any ideas?

Thanks,
Romain



More information about the vtkusers mailing list