[vtkusers] trouble in saving an image in VTK
dev
work2compilation at gmail.com
Thu Dec 8 10:04:59 EST 2011
Hi all,
I got the Zbuffer from the renderer Window:
*float* zbuffer=renderWindow->GetZbufferData(0,0,HEIGHT-1,WIDTH-1);*
And I save this zbuffer to an image (bmp), using a function:
http://vtk.1045678.n5.nabble.com/file/n5059065/depth.jpg
*SaveZBufferToImage( HEIGHT-1 , WIDTH-1, zbuffer1 , "zbuffer1.bmp" ); *
I put the code of SaveZbufferToImage function here:
void SaveZBufferToImage( int height , int width , float *ZBuffer , const
char *FileImage )
{
vtkImageData *pZImage = vtkImageData::New();
pZImage->SetExtent( 0 , height , 0 , width , 0 ,0);
pZImage->SetOrigin( 0.0 , 0.0 , 0.0 );
pZImage->SetSpacing(1.0,1.0,1.0);
pZImage->SetScalarTypeToUnsignedChar();
pZImage->SetNumberOfScalarComponents( 1 );
pZImage->AllocateScalars();
unsigned char *zPtr= static_cast<unsigned char *>
(pZImage->GetScalarPointer(0.0,0.0,0.0));
for( int i = 0 ; i < height * width ; i++ )
{
zPtr[i] = 255-ZBuffer[i]*255;
}
vtkBMPWriter *pDepthImageWriter = vtkBMPWriter::New();
pDepthImageWriter->SetInput( pZImage );
pDepthImageWriter->SetFileName( FileImage );
pDepthImageWriter->Write();
}
And I get an image with a *white band above as you can see in the image that
I attached*. Perhaps I have a problem of dimensions, but I didn't find
anything.
Please help
Thank you
--
View this message in context: http://vtk.1045678.n5.nabble.com/trouble-in-saving-an-image-in-VTK-tp5059065p5059065.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list