From f821def1eb93121728015e4e84b2c9d24ee1ccf1 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 14 Apr 2020 12:51:09 -0700 Subject: [PATCH] Handle 2x scaling in plot drawing old-commit-hash: e816467eb5a6fb7b933225a871dc8ad339a17e68 --- tools/replay/lib/ui_helpers.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/replay/lib/ui_helpers.py b/tools/replay/lib/ui_helpers.py index 242e5a0c25..1cf8ee99a8 100644 --- a/tools/replay/lib/ui_helpers.py +++ b/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