[vtkusers] vtkImageAppend lost color
Tracy Hu
tracy.hu at yahoo.com
Thu Jan 3 12:00:45 EST 2008
I added a colored image to vtkImageAppend, which produced an image without color.
The color array in its output also contains different values from that in original image:(100, 0, 0)(0,0,0)(100,0,0)(0,0,0)
Do you know what I did wrong? thank you very much. below is my code:
int main( int argc, char *argv[] )
{
vtkUnsignedCharArray *colorArray = vtkUnsignedCharArray::New();
colorArray->SetNumberOfComponents(3);
colorArray->InsertTuple3(0,100.0,0.0,0.0);
colorArray->InsertTuple3(1,100.0,0.0,0.0);
colorArray->InsertTuple3(2,100.0,0.0,0.0);
colorArray->InsertTuple3(3,100.0,0.0,0.0);
vtkImageData *image = vtkImageData::New();
image->SetDimensions(2,2,1);
image->SetSpacing(1.0,1.0,1.0);
image->SetOrigin(0.0,0.0,0.0);
image->SetScalarType(VTK_UNSIGNED_CHAR);
image->GetPointData()->SetScalars(colorArray);
vtkImageAppend *reader = vtkImageAppend::New();
reader->AddInput(image);
vtkDataSetMapper *mapper = vtkDataSetMapper::New();
mapper->SetInput(reader->GetOutput());
vtkActor *actor = vtkActor::New();
actor->SetMapper(mapper);
vtkRenderer* ren = vtkRenderer::New();
ren->AddActor(actor);
ren->SetBackground(1, 1, 1);
vtkRenderWindow* renWin = vtkRenderWindow::New();
renWin->AddRenderer(ren);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
vtkInteractorStyleTrackballCamera *style = vtkInteractorStyleTrackballCamera::New();
iren->SetInteractorStyle(style);
renWin->SetSize(600,600);
renWin->Render();
iren->Start();
style->Delete();
iren->Delete();
ren->Delete();
renWin->Delete();
actor->Delete();
mapper->Delete();
reader->Delete();
return 0;
}
---------------------------------
Looking for last minute shopping deals? Find them fast with Yahoo! Search.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080103/f4766b45/attachment.htm>
More information about the vtkusers
mailing list