mirror of
https://github.com/holub/mame
synced 2025-04-19 23:12:11 +03:00
ui/selmenu.cpp: Allow icons to be scaled up as well as down (#12851)
This commit is contained in:
parent
510d5edf29
commit
2a68e37525
@ -1361,20 +1361,20 @@ bool menu_select_launch::scale_icon(bitmap_argb32 &&src, texture_and_bitmap &dst
|
||||
assert(dst.texture);
|
||||
if (src.valid())
|
||||
{
|
||||
// reduce the source bitmap if it's too big
|
||||
// scale the source bitmap
|
||||
bitmap_argb32 tmp;
|
||||
float const ratio((std::min)({ float(m_icon_height) / src.height(), float(m_icon_width) / src.width(), 1.0F }));
|
||||
if (1.0F > ratio)
|
||||
float const ratio((std::min)({ float(m_icon_height) / src.height(), float(m_icon_width) / src.width() }));
|
||||
if (1.0F == ratio)
|
||||
{
|
||||
tmp = std::move(src);
|
||||
}
|
||||
else
|
||||
{
|
||||
float const pix_height(std::ceil(src.height() * ratio));
|
||||
float const pix_width(std::ceil(src.width() * ratio));
|
||||
tmp.allocate(s32(pix_width), s32(pix_height));
|
||||
render_resample_argb_bitmap_hq(tmp, src, render_color{ 1.0F, 1.0F, 1.0F, 1.0F }, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp = std::move(src);
|
||||
}
|
||||
|
||||
// copy into the destination
|
||||
dst.bitmap.allocate(m_icon_width, m_icon_height);
|
||||
|
Loading…
Reference in New Issue
Block a user