1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 10:42:36 +01:00

overlays: Fix aspect ratio of custom bakground images

This commit is contained in:
Megamouse 2021-03-14 11:38:01 +01:00
parent 8b0cd60be9
commit 1a5a0f5eca

View File

@ -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<u8>(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<double>(background_image->h)) > (background_poster.w / static_cast<double>(background_poster.h)))
{
const int padding = (background_poster.h - (background_image->h * (background_poster.w / static_cast<double>(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<double>(background_image->h)))) / 2;
background_poster.set_padding(padding, padding, 0, 0);
}
}
}
}