about summary refs log tree commit diff stats
path: root/tracker_panel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tracker_panel.cpp')
-rw-r--r--tracker_panel.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/tracker_panel.cpp b/tracker_panel.cpp index 74bf605..38d7c86 100644 --- a/tracker_panel.cpp +++ b/tracker_panel.cpp
@@ -21,7 +21,26 @@ void TrackerPanel::OnPaint(wxPaintEvent &event) {
21} 21}
22 22
23void TrackerPanel::Redraw() { 23void TrackerPanel::Redraw() {
24 wxSize sz = GetSize(); 24 wxSize panel_size = GetSize();
25 wxSize image_size = map_image_.GetSize();
26
27 int final_x = 0;
28 int final_y = 0;
29 int final_width = panel_size.GetWidth();
30 int final_height = panel_size.GetHeight();
31
32 if (image_size.GetWidth() * panel_size.GetHeight() >
33 panel_size.GetWidth() * image_size.GetHeight()) {
34 final_height = (panel_size.GetWidth() * image_size.GetHeight()) /
35 image_size.GetWidth();
36 final_y = (panel_size.GetHeight() - final_height) / 2;
37 } else {
38 final_width = (image_size.GetWidth() * panel_size.GetHeight()) /
39 image_size.GetHeight();
40 final_x = (panel_size.GetWidth() - final_width) / 2;
41 }
42
25 rendered_ = wxBitmap( 43 rendered_ = wxBitmap(
26 map_image_.Scale(sz.GetWidth(), sz.GetHeight(), wxIMAGE_QUALITY_NORMAL)); 44 map_image_.Scale(final_width, final_height, wxIMAGE_QUALITY_NORMAL)
45 .Size(panel_size, {final_x, final_y}, 0, 0, 0));
27} 46}