[vtkusers] About the screenshot
Shaofan
chi.cedric at gmail.com
Mon Sep 19 11:51:09 EDT 2011
Hi,
I have a problem when I run the example of the Vtk screenshot at
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Utilities/Screenshot. The output
image is all black!!!
What's wrong with my computer? Is there something wrong when I compile the
Vtk?
My platform is Windows 7 32-bit. Vs2010.Vtk 5.8.o
***********************the code**********************************
vtkConeSource*cone=vtkConeSource::New();
cone->SetHeight(3.0);
cone->SetRadius(1.0);
cone->SetResolution(89);
vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();
coneMapper->SetInputConnection( cone->GetOutputPort());
vtkTextMapper *text= vtkTextMapper::New();
text->SetInput("Shaofan Qi's Homework");
text->GetTextProperty()->SetColor(1,1,1);
text->GetTextProperty()->SetFontSize(24);
vtkActor *coneActor= vtkActor::New();
coneActor->SetMapper( coneMapper );
vtkActor2D *textActor = vtkActor2D::New();
textActor->SetMapper(text);
textActor->SetDisplayPosition(210,10);
vtkRenderer *renderer = vtkRenderer::New();
renderer->AddActor( coneActor );
renderer->AddActor2D( textActor );
renderer->SetBackground(0.1,0.1,0.9);
vtkRenderWindow *win = vtkRenderWindow::New();
win->AddRenderer(renderer);
win->SetSize( 700,300 );
for (int i = 0; i < 360; i++)
{
win->Render();
renderer->GetActiveCamera()->Azimuth( 1 );
// Screenshot
if (i%90==0)
{
vtkWindowToImageFilter *imfilter =
vtkWindowToImageFilter::New();
imfilter->Modified();
imfilter->SetInput(win);
imfilter->SetInputBufferTypeToRGB();
imfilter->Update();
vtkPNGWriter *writer1 = vtkPNGWriter::New();
writer1->SetFileName("1");
writer1->SetInput(imfilter->GetOutput());
writer1->Write();
}
}
cone->Delete();
coneActor->Delete();
coneMapper->Delete();
text->Delete();
textActor->Delete();
win->Delete();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110919/1a72f823/attachment.htm>
More information about the vtkusers
mailing list