diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-05-01 19:12:45 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-05-01 19:12:45 -0400 |
commit | f7530492119f94a83bdb85bb3887b50ddb5a6ffd (patch) | |
tree | 6e460e2e1f03e79836752b2408bc0b4f46b79df9 /tracker_panel.cpp | |
parent | 9798316b43773e4c7d15851202977a3069f28577 (diff) | |
download | lingo-ap-tracker-f7530492119f94a83bdb85bb3887b50ddb5a6ffd.tar.gz lingo-ap-tracker-f7530492119f94a83bdb85bb3887b50ddb5a6ffd.tar.bz2 lingo-ap-tracker-f7530492119f94a83bdb85bb3887b50ddb5a6ffd.zip |
Map image now has aspect ratio maintained
Diffstat (limited to 'tracker_panel.cpp')
-rw-r--r-- | tracker_panel.cpp | 23 |
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 | ||
23 | void TrackerPanel::Redraw() { | 23 | void 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 | } |