From 453c5cda0767184da046bf0439fe22cf6e6bbdc0 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Thu, 8 Jun 2023 13:09:33 +1000 Subject: [PATCH] Added oleaut32-default-pic-size patchset --- ...ntially-load-icons-having-the-desire.patch | 82 +++++++++++++++++++ patches/oleaut32-default-pic-size/definition | 1 + 2 files changed, 83 insertions(+) create mode 100644 patches/oleaut32-default-pic-size/0001-oleaut32-preferentially-load-icons-having-the-desire.patch create mode 100644 patches/oleaut32-default-pic-size/definition diff --git a/patches/oleaut32-default-pic-size/0001-oleaut32-preferentially-load-icons-having-the-desire.patch b/patches/oleaut32-default-pic-size/0001-oleaut32-preferentially-load-icons-having-the-desire.patch new file mode 100644 index 00000000..dad7dd7a --- /dev/null +++ b/patches/oleaut32-default-pic-size/0001-oleaut32-preferentially-load-icons-having-the-desire.patch @@ -0,0 +1,82 @@ +From e6f8042ee351aa6821639a1d99e003e8425c36e9 Mon Sep 17 00:00:00 2001 +From: Damjan Jovanovic +Date: Sat, 29 Feb 2020 09:21:55 +0200 +Subject: [PATCH] oleaut32: preferentially load icons having the desired size + in OleLoadPictureEx + +Currently OleLoadPictureEx() ignores the caller-desired icon size +and always loads the 32x32 icon, which sometimes has to be +scaled down to 16x16, resulting in quality loss. Change this +to load the icon having the desired size, falling back to 32x32 +only when the desired size is unavailable. + +Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=20732 + +Signed-off-by: Damjan Jovanovic + +Updated to default 32 when x/y are LP_DEFAULT. +--- + dlls/oleaut32/olepicture.c | 22 ++++++++++++++++++---- + 1 file changed, 18 insertions(+), 4 deletions(-) + +diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c +index 535a16146aa..05ad1137296 100644 +--- a/dlls/oleaut32/olepicture.c ++++ b/dlls/oleaut32/olepicture.c +@@ -151,6 +151,8 @@ typedef struct OLEPictureImpl { + BOOL bIsDirty; /* Set to TRUE if picture has changed */ + unsigned int loadtime_magic; /* If a length header was found, saves value */ + unsigned int loadtime_format; /* for PICTYPE_BITMAP only, keeps track of image format (GIF/BMP/JPEG) */ ++ DWORD desiredWidth; ++ DWORD desiredHeight; + } OLEPictureImpl; + + static inline OLEPictureImpl *impl_from_IPicture(IPicture *iface) +@@ -1190,14 +1192,20 @@ static HRESULT OLEPictureImpl_LoadIcon(OLEPictureImpl *This, BYTE *xbuf, ULONG x + return E_FAIL; + } + i=0; +- /* If we have more than one icon, try to find the best. +- * this currently means '32 pixel wide'. +- */ + if (cifd->idCount!=1) { ++ /* First try exact match on the desired dimensions */ + for (i=0;iidCount;i++) { +- if (cifd->idEntries[i].bWidth == 32) ++ if (cifd->idEntries[i].bWidth == This->desiredWidth && ++ cifd->idEntries[i].bHeight == This->desiredHeight) + break; + } ++ /* Otherwise, try to find the best. This currently means '32 pixel wide'. */ ++ if (i==cifd->idCount) { ++ for (i=0;iidCount;i++) { ++ if (cifd->idEntries[i].bWidth == 32) ++ break; ++ } ++ } + if (i==cifd->idCount) i=0; + } + if (xread < cifd->idEntries[i].dwDIBOffset + cifd->idEntries[i].dwDIBSize) +@@ -2356,6 +2364,7 @@ HRESULT WINAPI OleLoadPictureEx( LPSTREAM lpstream, LONG lSize, BOOL fRunmode, + { + LPPERSISTSTREAM ps; + IPicture *newpic; ++ OLEPictureImpl *pictureImpl; + HRESULT hr; + + FIXME("%p, %ld, %d, %s, %lu, %lu, %#lx, %p, partially implemented.\n", +@@ -2364,6 +2373,11 @@ HRESULT WINAPI OleLoadPictureEx( LPSTREAM lpstream, LONG lSize, BOOL fRunmode, + hr = OleCreatePictureIndirect(NULL,riid,!fRunmode,(LPVOID*)&newpic); + if (hr != S_OK) + return hr; ++ if (xsiz == LP_DEFAULT && ysiz == LP_DEFAULT) ++ xsiz = ysiz = 32; ++ pictureImpl = impl_from_IPicture(newpic); ++ pictureImpl->desiredWidth = xsiz; ++ pictureImpl->desiredHeight = ysiz; + hr = IPicture_QueryInterface(newpic,&IID_IPersistStream, (LPVOID*)&ps); + if (hr != S_OK) { + ERR("Could not get IPersistStream iface from Ole Picture?\n"); +-- +2.40.1 + diff --git a/patches/oleaut32-default-pic-size/definition b/patches/oleaut32-default-pic-size/definition new file mode 100644 index 00000000..2151be71 --- /dev/null +++ b/patches/oleaut32-default-pic-size/definition @@ -0,0 +1 @@ +Fixes: [20732] OleLoadPictureEx - First look for specific size if specified.