Skip to content

Changing size of background canvas makes ugly PNGs #1148

@chaosphere2112

Description

@chaosphere2112

Ran into this issue while working on #1113; what happens is this:

import vcs, cdms2, sys, os
cfile = cdms2.open(os.path.join(sys.prefix, "sample_data", "clt.nc"))
x = vcs.init()
x.plot(cfile["clt"], bg=1)
x.png("orig.png")
x.bgX = 1000
x.bgY = 750
x.update()
x.png("resize.png")

and you get these outputs:

orig.png

orig

resize.png

resize

This looks to be an issue with VTK's handling of resizing a background window, not something we're doing:

import vtk

win = vtk.vtkRenderWindow()
win.SetSize(300, 300)

ren = vtk.vtkRenderer()
ren.SetBackground(.5, .4, .3)

win.AddRenderer(ren)
win.SetOffScreenRendering(True)

filter = vtk.vtkWindowToImageFilter()
filter.SetInput(win)
filter.Update()

writer = vtk.vtkPNGWriter()
writer.SetInputConnection(filter.GetOutputPort())
writer.SetFileName("base.png")
writer.Write()

win.SetSize(600, 300)
filter = vtk.vtkWindowToImageFilter()
filter.SetInput(win)
filter.Update()

writer.SetInputConnection(filter.GetOutputPort())
writer.SetFileName("resized.png")
writer.Write()

base.png

base

resized.png

resized

If you do the same but with OffScreenRendering False, you get the expected images.

@aashish24 @doutriaux1 This is the source of my only outstanding concerns on #1113. I've got fixes that make the animation behave "correctly" but trigger this bug, but I'd say that the way it behaves currently (where it will always render the animation at the original resolution of the render window) is less bad than this bug.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions