Skip to content
Snippets Groups Projects
Commit afca3a76 authored by Sankhesh Jhaveri's avatar Sankhesh Jhaveri :speech_balloon:
Browse files

Fix image blend test to ensure that the right images are blended

Explicitly initialize values to 0 in vtkImageCanvasSource2D when creating
the alpha component for backgroundAlpha
parent c21959f0
No related branches found
No related tags found
No related merge requests found
08e4830abc621e369647f3f21d91014bc2aa8bbeec41bb51634e403584bb6c17c1a94accd7d01ff07f8d520d0953807a8e00816e60899f3d09b3a7c60e26aaf3
74f0e472690a9a8ed6cab27877266378e218ba30c5eac05c4dc8ca026bec3608bf85cc004277c5517c72a7476bb03cacad98a1481975dbc46b359ae9c84fcf6e
......@@ -72,6 +72,8 @@ bmask = vtk.vtkImageCanvasSource2D()
bmask.SetScalarTypeToUnsignedChar()
bmask.SetNumberOfScalarComponents(1)
bmask.SetExtent(0, 127, 0, 127, 0, 0)
bmask.SetDrawColor(0)
bmask.FillPixel(64, 64)
bmask.SetDrawColor(255)
bmask.DrawCircle(64, 64, 40)
bmask.FillPixel(64, 64)
......@@ -96,15 +98,17 @@ for row, bg in enumerate(backgrounds):
blend.update({bg:{fg:vtk.vtkImageBlend()}})
blend[bg][fg].AddInputConnection(eval(bg + '.GetOutputPort()'))
blend[bg][fg].SetBlendModeToCompound()
if bg == "backgroundColor" or fg == "luminance" or fg == "luminanceAlpha":
if bg == "backgroundAlpha" or bg == "backgroundColor":
blend[bg][fg].AddInputConnection(eval(fg + '.GetOutputPort()'))
blend[bg][fg].SetOpacity(1, 0.8)
if bg == "backgroundAlpha" and (fg == "color" or fg ==
"colorAlpha"):
if bg == "backgroundAlpha":
blend[bg][fg].SetCompoundAlpha(True)
blend[bg][fg].SetOpacity(0, 0.5)
blend[bg][fg].SetOpacity(1, 0.5)
else:
blend[bg][fg].SetOpacity(1, 0.8)
elif fg == "luminance" or fg == "luminanceAlpha":
blend[bg][fg].AddInputConnection(eval(fg + '.GetOutputPort()'))
blend[bg][fg].SetCompoundAlpha(True)
blend[bg][fg].SetOpacity(0, 0.5)
blend[bg][fg].SetOpacity(1, 0.5)
blend[bg][fg].SetOpacity(1, 0.8)
mapper.update({bg:{fg:vtk.vtkImageMapper()}})
mapper[bg][fg].SetInputConnection(blend[bg][fg].GetOutputPort())
......@@ -117,6 +121,7 @@ for row, bg in enumerate(backgrounds):
imager.update({bg:{fg:vtk.vtkRenderer()}})
imager[bg][fg].AddActor2D(actor[bg][fg])
imager[bg][fg].SetViewport(column * deltaX, row * deltaY, (column + 1) * deltaX, (row + 1) * deltaY)
imager[bg][fg].SetBackground(0.3, 0.3, 0.3)
renWin.AddRenderer(imager[bg][fg])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment