[vtkusers] vtkImageImport , vtkImageViewer : window black
Olaf Till
olaf.till at uni-jena.de
Thu Nov 6 07:00:25 EST 2008
Hi,
I try to use VDK to render images from memory. As yet, I only get
windows filled with black. The following is some example code, which
produces a black window, although I thought that half of the image
should be white. Can you give me a hint what is the reason?
Olaf
--- example code ---
#include <unistd.h>
#include <vtk-5.0/vtkImageImport.h>
#include <vtk-5.0/vtkImageViewer.h>
// compile with: g++ -Wno-deprecated -ggdb -lvtkRendering -lvtkImaging -o render-image-test render-image-test.cc
int
main (int argc, char **argv) {
unsigned char buffer[64] =
{255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0};
vtkImageImport *importer = vtkImageImport::New();
importer->SetWholeExtent(0,7,0,7,0,0);
importer->SetDataExtentToWholeExtent();
importer->SetDataScalarTypeToUnsignedChar();
importer->SetImportVoidPointer(buffer);
vtkImageViewer *viewer = vtkImageViewer::New();
viewer->SetInputConnection(importer->GetOutputPort());
viewer->Render();
sleep (5);
}
More information about the vtkusers
mailing list