[vtkusers] save a volume view as a MetaImage file

Kevin H. Hobbs hobbsk at ohiou.edu
Thu Jan 15 07:35:13 EST 2009


On Thursday 15 January 2009 06:55:32 Stéphane CALANDE wrote:
> Hi vtk users,
>
>
> I'm doing volume rendering but I would like to save a view into a MetaImage
> file.
>
> I don't know exactly which input I have to give to the meta image writer.
>
> Can you help me ?
>

It sounds like you are trying to save a 2D image of what you see on the 
screen. You need something like :

	// Renderer
	vtkRenderer * renderer = vtkRenderer::New();
	renderer->AddVolume( volume );

	// Render Window
	vtkRenderWindow * render_window = vtkRenderWindow::New();
	render_window->AddRenderer( renderer );

	// Window to Image	
	vtkWindowToImageFilter * win_2_image 
		= vtkWindowToImageFilter::New();
        win_2_image->SetInputBufferTypeToRGBA();
	win_2_image->SetInput( render_window );

	// PNG Writer
	vtkPNGWriter * writer = vtkPNGWriter::New();
	writer->SetFileName( out_file_name );
	writer->SetInputConnection( win_2_image->GetOutputPort() );

	render_window->Render();

	writer->Write();

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090115/3848a9f1/attachment.pgp>


More information about the vtkusers mailing list