mirror of
https://github.com/stenzek/duckstation.git
synced 2026-02-10 08:24:32 +00:00
Sharper icon scaling (#3553)
* take ceiling instead of truncation for icon scaling * #include <cmath> and change std::ceilf to std::ceil
This commit is contained in:
committed by
GitHub
parent
3ff6287a82
commit
587e73d71d
@@ -35,6 +35,7 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <cmath>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include "common/windows_headers.h"
|
||||
@@ -330,12 +331,12 @@ template<typename T>
|
||||
static void ResizeSharpBilinearT(T& pm, int size, int base_size)
|
||||
{
|
||||
// Sharp Bilinear scaling
|
||||
// First, scale the icon by the largest integer size using nearest-neighbor...
|
||||
const int integer_icon_size = static_cast<int>(size / base_size) * base_size;
|
||||
// First, scale the icon by the next largest integer size using nearest-neighbor...
|
||||
const int integer_icon_size = std::ceil(static_cast<float>(size) / base_size) * base_size;
|
||||
pm = pm.scaled(integer_icon_size, integer_icon_size, Qt::IgnoreAspectRatio, Qt::FastTransformation);
|
||||
|
||||
// ...then scale any remainder using bilinear interpolation.
|
||||
if (size - integer_icon_size > 0)
|
||||
// ...then scale down any remainder using bilinear interpolation.
|
||||
if (integer_icon_size - size > 0)
|
||||
pm = pm.scaled(size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user