From 1a5a0f5eca8f665402a8884621460ebb0e23fb3f Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sun, 14 Mar 2021 11:38:01 +0100 Subject: [PATCH] overlays: Fix aspect ratio of custom bakground images --- .../Emu/RSX/Overlays/overlay_message_dialog.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp b/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp index 7dc6aa2f46..4a8cf8775d 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp @@ -71,6 +71,22 @@ namespace rsx background_poster.set_size(1280, 720); background_poster.set_raw_image(background_image.get()); background_poster.set_blur_strength(static_cast(g_cfg.video.shader_preloading_dialog.blur_strength)); + + ensure(background_image->w > 0); + ensure(background_image->h > 0); + ensure(background_poster.h > 0); + + // Set padding in order to keep the aspect ratio + if ((background_image->w / static_cast(background_image->h)) > (background_poster.w / static_cast(background_poster.h))) + { + const int padding = (background_poster.h - (background_image->h * (background_poster.w / static_cast(background_image->w)))) / 2; + background_poster.set_padding(0, 0, padding, padding); + } + else + { + const int padding = (background_poster.w - (background_image->w * (background_poster.h / static_cast(background_image->h)))) / 2; + background_poster.set_padding(padding, padding, 0, 0); + } } } }