Handle 2x scaling in plot drawing

old-commit-hash: e816467eb5
commatwo_master
Willem Melching 5 years ago
parent 746600dfb3
commit f821def1eb
  1. 10
      tools/replay/lib/ui_helpers.py

@ -173,8 +173,14 @@ def init_plots(arr, name_to_arr_idx, plot_xlims, plot_ylims, plot_names, plot_co
fig.canvas.flush_events()
raw_data = renderer.tostring_rgb()
#print fig.canvas.get_width_height()
plot_surface = pygame.image.frombuffer(raw_data, fig.canvas.get_width_height(), "RGB").convert()
x, y = fig.canvas.get_width_height()
# Handle 2x scaling
if len(raw_data) == 4 * x * y * 3:
plot_surface = pygame.image.frombuffer(raw_data, (2*x, 2*y), "RGB").convert()
plot_surface = pygame.transform.scale(plot_surface, (x, y))
else:
plot_surface = pygame.image.frombuffer(raw_data, fig.canvas.get_width_height(), "RGB").convert()
return plot_surface
return draw_plots

Loading…
Cancel
Save