Skip to content

Commit

Permalink
[win32] Disable automatic thumbnail squaring for everything except IE…
Browse files Browse the repository at this point in the history
…xtractIcon.

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.
  • Loading branch information
GerbilSoft committed Jul 15, 2023
1 parent 0956e61 commit 4617696
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 2 additions & 3 deletions src/win32/CreateThumbnail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* ROM Properties Page shell extension. (Win32) *
* CreateThumbnail.cpp: TCreateThumbnail<HBITMAP> implementation. *
* *
* Copyright (c) 2016-2022 by David Korth. *
* Copyright (c) 2016-2023 by David Korth. *
* SPDX-License-Identifier: GPL-2.0-or-later *
***************************************************************************/

Expand Down Expand Up @@ -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);
Expand Down
17 changes: 15 additions & 2 deletions src/win32/CreateThumbnail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
class CreateThumbnail : public LibRomData::TCreateThumbnail<HBITMAP>
{
public:
explicit CreateThumbnail() = default;
explicit CreateThumbnail(bool doSquaring = false)
{
m_doSquaring = doSquaring;
}

private:
typedef TCreateThumbnail<HBITMAP> super;
Expand Down Expand Up @@ -102,6 +105,14 @@ class CreateThumbnail : public LibRomData::TCreateThumbnail<HBITMAP>
* @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;
};

/**
Expand All @@ -112,7 +123,9 @@ class CreateThumbnail : public LibRomData::TCreateThumbnail<HBITMAP>
class CreateThumbnailNoAlpha final : public CreateThumbnail
{
public:
explicit CreateThumbnailNoAlpha() = default;
explicit CreateThumbnailNoAlpha(bool doSquaring = false)
: super(doSquaring)
{ }

private:
typedef CreateThumbnail super;
Expand Down
1 change: 1 addition & 0 deletions src/win32/RP_ExtractIcon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 4617696

Please sign in to comment.