[vtkusers] generate vtkImageData

Andreas Gamber agamber at gmx.de
Tue Apr 3 06:26:40 EDT 2007


Hello everyone,

does anyone know a possibility to generate a vtkImageData-Object containing graphical data and text in a dynamic way?

It is possible to solve this problem by adding the graphical data and the text to an actor and using the
vtkWindowToImageFilter to generate a vtkImageData-object from the vtkRenderWindow-object.


// **********************************************************************
Example:

vtkRenderWindow *renderWindow = vtkRenderWindow::New();
vtkRenderer *renderer = vtkRenderer::New();
...

vtkTextActor *text = vtkTextActor::New();
text->SetPosition(10,10); 
text->SetInput("Hello World!");

vtkTextProperty *textProp = text->GetTextProperty();
textProp->SetFontSize(12);
textProp->SetJustificationToLeft();
textProp->BoldOn();
textProp->SetColor(0,0,0);

renderer->AddActor2D(text);

...

renderWindow->AddRenderer(renderer);
renderWindow->Render();

vtkWindowToImageFilter *windowToImage = vtkWindowToImageFilter::New();

windowToImage->SetInput(renderWindow);
windowToImage->Update();

vtkImageData *resultImage = windowToImage->GetOutput();

// **********************************************************************


 
But I guess there must be a better way to generate the vtkImageData-object without using any kind of rendering.


Thank you in advance,
Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070403/6081443b/attachment.htm>


More information about the vtkusers mailing list