AW: [vtkusers] How to render vtkImageData with vtkActor2D?

jiang jiang at TI.Uni-Trier.DE
Thu Jan 15 03:09:57 EST 2004


Hi, all,
I find out the solution for this problem.
I use vtkDataSetMapper and vtkActor to render this vtkImageData. Then it
works.


Cheers,

Chunyan

-----Ursprüngliche Nachricht-----
Von: vtkusers-admin at vtk.org [mailto:vtkusers-admin at vtk.org]Im Auftrag
von jiang
Gesendet: Mittwoch, 14. Januar 2004 15:03
An: VTK
Betreff: [vtkusers] How to render vtkImageData with vtkActor2D?


Hello vtk-users,
I have one vtkImageData. It is 2D image. So I can render it as following:
	vtkImageActor *actor=vtkImageActor::New();
	actor->SetInput(ImageData);
  	int ext[6];
 	actor->GetInput()->GetExtent( ext );
	ext[4]=0;ext[5]=0;
      actor->SetDisplayExtent( ext );

      vtkRenderer *renderer=vtkRenderer::New();
	renderer->AddActor(actor);
	vtkRenderWindow *renderWin=vtkRenderWindow::New();
	renderWin->AddRenderer(renderer);

      renderWin->Render();

Now I want to use vtkActor2D instead of vtkImageData. Because I want to set
the image as semi-transparent. I have to
use ->GetProperty()->SetOpacity(0.5). vtkImageActor has not GetProperty()
member function.
I do it as following:
	vtkImageMapper ImageMapper=vtkImageMapper::New();
	ImageMapper->SetInput(ImageData);
	ImageMapper->SetZSlice(0);

	vtkActor2D *actor=vtkActor2D::New();
	actor->SetMapper(ImageMapper);
	actor->GetProperty()->SetOpacity(0.5);

      vtkRenderer *renderer=vtkRenderer::New();
	renderer->AddActor(actor);
	vtkRenderWindow *renderWin=vtkRenderWindow::New();
	renderWin->AddRenderer(renderer);

      renderWin->Render();

However it doesn't work. I can only see one black image. How should I do?

Thank you very much!

Chunyan

_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers




More information about the vtkusers mailing list