From 46176961812a5cbf2020e7ad8c94f6f85f460349 Mon Sep 17 00:00:00 2001 From: David Korth Date: Sat, 15 Jul 2023 11:51:38 -0400 Subject: [PATCH] [win32] Disable automatic thumbnail squaring for everything except IExtractIcon. It seems this causes cover art for e.g. Wii U and PS2 to be squished. I'm pretty sure it worked before, though... The Win32 CreateThumbnail class now takes a parameter, doSquaring. It's set to false by default, but RP_ExtractIcon sets it to true. CreateThumbnail::rpImageToImgClass() will only square the image if the doSquaring parameter was set to true in the constructor. CreateThumbnailNoAlpha also has the parameter, though since this class is only used by RP_ExtractImage, it will stay false. Fixes #385: Ratio of ps2 longbox thumbnails looks wrong? Reported by @Masamune3210. --- NEWS.md | 3 +++ src/win32/CreateThumbnail.cpp | 5 ++--- src/win32/CreateThumbnail.hpp | 17 +++++++++++++++-- src/win32/RP_ExtractIcon.cpp | 1 + 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/NEWS.md b/NEWS.md index 23147a039..407c5022f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -18,6 +18,9 @@ * This was broken in v2.2. * Fixes #389: Gamecube Property sheet is blank * Reported by @Masamune3210. + * Windows: Don't square thumbnails for anything except icon extraction. + * Fixes #385: Ratio of ps2 longbox thumbnails looks wrong? + * Reported by @Masamune3210. ## v2.2 (released 2023/07/01) diff --git a/src/win32/CreateThumbnail.cpp b/src/win32/CreateThumbnail.cpp index ec219d550..9097bfe87 100644 --- a/src/win32/CreateThumbnail.cpp +++ b/src/win32/CreateThumbnail.cpp @@ -2,7 +2,7 @@ * ROM Properties Page shell extension. (Win32) * * CreateThumbnail.cpp: TCreateThumbnail implementation. * * * - * Copyright (c) 2016-2022 by David Korth. * + * Copyright (c) 2016-2023 by David Korth. * * SPDX-License-Identifier: GPL-2.0-or-later * ***************************************************************************/ @@ -51,9 +51,8 @@ HBITMAP CreateThumbnail::rpImageToImgClass(const rp_image *img) const // Windows doesn't like non-square icons. // Add extra transparent columns/rows before // converting to HBITMAP. - // TODO: Disable this for RP_ExtractImage and RP_ThumbnailProvider? rp_image *tmp_img = nullptr; - if (!img->isSquare()) { + if (m_doSquaring && !img->isSquare()) { // Image is non-square. tmp_img = img->squared(); assert(tmp_img != nullptr); diff --git a/src/win32/CreateThumbnail.hpp b/src/win32/CreateThumbnail.hpp index e95255aef..454fa84cc 100644 --- a/src/win32/CreateThumbnail.hpp +++ b/src/win32/CreateThumbnail.hpp @@ -18,7 +18,10 @@ class CreateThumbnail : public LibRomData::TCreateThumbnail { public: - explicit CreateThumbnail() = default; + explicit CreateThumbnail(bool doSquaring = false) + { + m_doSquaring = doSquaring; + } private: typedef TCreateThumbnail super; @@ -102,6 +105,14 @@ class CreateThumbnail : public LibRomData::TCreateThumbnail * @return True if metered; false if not. */ bool isMetered(void) final; + + private: + // Enable automatic squaring of thumbnails when converting to the + // native OS image class. This is needed for icons. + // - IExtractIcon: squared + // - IExtractImage: not squared + // - IThumbnailProvider: not squared + bool m_doSquaring; }; /** @@ -112,7 +123,9 @@ class CreateThumbnail : public LibRomData::TCreateThumbnail class CreateThumbnailNoAlpha final : public CreateThumbnail { public: - explicit CreateThumbnailNoAlpha() = default; + explicit CreateThumbnailNoAlpha(bool doSquaring = false) + : super(doSquaring) + { } private: typedef CreateThumbnail super; diff --git a/src/win32/RP_ExtractIcon.cpp b/src/win32/RP_ExtractIcon.cpp index cd5550360..0dcfc1680 100644 --- a/src/win32/RP_ExtractIcon.cpp +++ b/src/win32/RP_ExtractIcon.cpp @@ -30,6 +30,7 @@ const CLSID CLSID_RP_ExtractIcon = RP_ExtractIcon_Private::RP_ExtractIcon_Private() : filename(nullptr) , romData(nullptr) + , thumbnailer(true) // enable automatic squaring { } RP_ExtractIcon_Private::~RP_ExtractIcon_Private()