fix off-by-1 error for memcard editor icon size

pull/3542/head
ANK-dev 2 months ago
parent d499d8e2d8
commit a2f6dd5b67

@ -37,7 +37,9 @@ static constexpr std::array<std::pair<ConsoleRegion, const char*>, 3> MEMORY_CAR
{ConsoleRegion::NTSC_J, "BI"},
{ConsoleRegion::PAL, "BE"},
}};
static constexpr int MEMORY_CARD_ICON_SIZE = MemoryCardImage::ICON_HEIGHT * 2;
// -1: QRect::width() and QRect::height() are inclusive, needs -1 to compensate. Fixes uneven scaling.
static constexpr int MEMORY_CARD_ICON_SIZE = MemoryCardImage::ICON_HEIGHT * 2 - 1;
static constexpr int MEMORY_CARD_ICON_FRAME_DURATION_MS = 200;
namespace {
@ -86,8 +88,8 @@ public:
// doing this on the UI thread is a bit ehh, but whatever, they're small images.
const MemoryCardImage::IconFrame& frame = fi.icon_frames[real_frame_index];
const int pixmap_width = static_cast<int>(std::ceil(static_cast<qreal>(rc.width() - 1) * dpr));
const int pixmap_height = static_cast<int>(std::ceil(static_cast<qreal>(rc.height() - 1) * dpr));
const int pixmap_width = static_cast<int>(std::ceil(static_cast<qreal>(rc.width()) * dpr));
const int pixmap_height = static_cast<int>(std::ceil(static_cast<qreal>(rc.height()) * dpr));
const int icon_size = std::min(pixmap_width, pixmap_height);
const int xoffs =
std::max(static_cast<int>((static_cast<qreal>(pixmap_width - icon_size) * static_cast<qreal>(0.5)) / dpr), 0);

Loading…
Cancel
Save