Skip to content

Commit

Permalink
ui/selmenu.cpp: Allow icons to be scaled up as well as down (#12851)
Browse files Browse the repository at this point in the history
  • Loading branch information
jflatt authored Nov 30, 2024
1 parent 510d5ed commit 2a68e37
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/frontend/mame/ui/selmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2a68e37

Please sign in to comment.