MCPcopy Create free account
hub / github.com/Kitware/VTK / CaptureRenderWindow

Class CaptureRenderWindow

Web/Python/vtkmodules/web/dataset_builder.py:25–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23
24
25class CaptureRenderWindow(object):
26 def __init__(self, magnification=1):
27 self.windowToImage = vtkWindowToImageFilter()
28 self.windowToImage.SetScale(magnification)
29 self.windowToImage.SetInputBufferTypeToRGB()
30 self.windowToImage.ReadFrontBufferOn()
31 self.writer = None
32
33 def SetRenderWindow(self, renderWindow):
34 self.windowToImage.SetInput(renderWindow)
35
36 def SetFormat(self, mimeType):
37 if mimeType == "image/png":
38 self.writer = vtkPNGWriter()
39 self.writer.SetInputConnection(self.windowToImage.GetOutputPort())
40 elif mimeType == "image/jpg":
41 self.writer = vtkJPEGWriter()
42 self.writer.SetInputConnection(self.windowToImage.GetOutputPort())
43
44 def writeImage(self, path):
45 if self.writer:
46 self.windowToImage.Modified()
47 self.windowToImage.Update()
48 self.writer.SetFileName(path)
49 self.writer.Write()
50
51
52# -----------------------------------------------------------------------------

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected