[vtkusers] Newbie Question RE vtkImageSource
Jeff Muller
jmuller at vcn.bc.ca
Thu Jun 5 21:29:37 EDT 2003
Hello all,
I'm new to vtk land.
I've been trying to get a memory buffer of my own displayed using a
vtkImageSource.
I know this should be simple but...
I'm trying to map a float array of 1501x1501 stored in image.
In the code below, using the imageMapper to map the import displays
nothing. Using imageMapper to map the vtkBMPReader (commented out)
instead of the the vtkImageImport works fine.
Is there anything I'm missing here?
I'm using the following code:
//======================================================
// Create the mapper and set the appropriate scalar range
vtkImageImport* import = vtkImageImport::New();
vtkImageImport* import = vtkImageImport::New();
import->SetDataScalarTypeToFloat();
import->SetDataExtent( 0, cols - 1,0,
0, rows - 1,0);
import->SetWholeExtent( 0, cols - 1,0,
0, rows - 1,0);
import->SetImportVoidPointer( (void*)image );
/* vtkBMPReader* reader = vtkBMPReader::New();
reader->SetFileName("d:\\data\\Winter.bmp");
*/
// Create the mapper and set the appropriate scalar range
// (default is (0,1)
vtkImageMapper* imgMapper = vtkImageMapper::New();
imgMapper->SetInput(import->GetOutput());
// imgMapper->SetInput(reader->GetOutput());
imgMapper->SetColorLevel(300.0f);
imgMapper->SetColorWindow(300.0f);
// Create an actor.
vtkActor2D* imgActor = vtkActor2D::New();
imgActor->SetMapper(imgMapper);
// Create the rendering objects.
vtkRenderer* ren = vtkRenderer::New();
ren->AddActor(imgActor);
vtkRenderWindow* renWin = vtkRenderWindow::New();
renWin->AddRenderer(ren);
vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
iren->Initialize();
iren->Start();
//======================================================
Thanks in advance.
More information about the vtkusers
mailing list