问题是我传递给vtkProperty的RGB值不会产生预期的颜色。例如,由RGB(146,110,218)识别的slateblue显示为白色。
以下是相关代码:
vtk.vtkLineSource line = new vtkLineSource();
line.SetPoint1(0.0, 0.0, 0.0);
line.SetPoint2(50, 50, 0.0);
vtkPolyDataMapper mapper = new vtkPolyDataMapper();
mapper.SetInput(line.GetOutput());
vtkActor lineActor = new vtkActor();
lineActor.SetMapper(mapper);
double r = 146.0;
double g = 110.0;
double b = 218.0;
vtkProperty property = new vtkProperty();
property.SetColor(r, g, b);
lineActor.SetProperty(property);
答案 0 :(得分:3)
此行为的原因是VTK使用标准化颜色值。
所以解决方案非常简单:我们必须将值除以255
[...]
double r = 146.0 / 255.0;
double g = 110.0 / 255.0;
double b = 218.0 / 255.0;
vtkProperty property = new vtkProperty();
property.SetColor(r, g, b);
lineActor.SetProperty(property);