[vtkusers] How to read and display a JPEG image
Elvis Dowson
elvis.dowson at mac.com
Fri Oct 3 12:02:16 EDT 2008
Hi,
I took a look at vtkActor2D, etc. The documentation is not
that helpful in figuring out what is going wrong. I think I have used
all the required methods in vtkActor2D, if you look at the code below,
such as using a JPEG reader, using an image mapper to prepare the
interface with vtkActor2D. But it still doesn't work.
For the moment, I don't want to use vtkTextureActor2D, since I don't
want to mess around with scaling or altering the geometric properties
of the 2D map that I am importing. The underlying image is a 2D map,
so I want it to be preserved with it's original properties.
Could someone help me get this to work with vtkActor2D ?
Best regards,
Elvis
// Declare object instance variables
vtkJPEGReader* imageReader;
vtkImageMapper* imageMapper;
vtkActor2D* mapActor;
// Initialize objects
imageReader = NULL;
imageMapper = NULL;
mapActor = NULL;
// Read 2D image file
imageReader = vtkJPEGReader::New();
imageReader->SetFileName("/Users/elvis/Project/C4I/Source/cxx/
vtkRendererMultiLayer/Dubai.A2003285.0655.250m.jpg");
imageReader->Update();
// Map 2D image file
imageMapper = vtkImageMapper::New();
imageMapper->SetInput(imageReader->GetOutput());
// Actor in scene
mapActor = vtkActor2D::New();
mapActor->SetLayerNumber(0);
mapActor->SetMapper(imageMapper);
// Add Actor to renderer
ren->AddActor2D(mapActor);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081003/9f496023/attachment.htm>
More information about the vtkusers
mailing list