https://bugs.winehq.org/show_bug.cgi?id=47076
Bug ID: 47076 Summary: LoadImage with option LR_SHARED and specified resolution does loading only that icon resolution, skipping others Product: Wine Version: 4.6 Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs@winehq.org Reporter: nikolaysemenkov@gmail.com Distribution: ---
LoadImage with option LR_SHARED and specified resolution(eg 32x32) does loading only that icon resolution, skipping others. Next time loading the same resource with all resolutions(by specifying 0,0) does return only the previously loaded resolution, skipping others. Putting that icon on a button makes button image giant due to wrong resolution.
eg: HICON hIconBig = (HICON)LoadImage(HInstance, MAKEINTRESOURCE(iIconLarge), IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR | LR_SHARED); Loads and cache only 32x32 image
LoadImage(LGetHInstance(), MAKEINTRESOURCE(iIconSmall), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR | LR_SHARED) Returns 32x32 from cache instead of 16x16
HICON hIcon2 = (HICON)LoadImage(HInstance, MAKEINTRESOURCE(iIconLarge), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_SHARED); Returns the 32x32 image, even though the icon(.ico resource) has images with other resolution.
To reproduce - load an icon from a resource with the resolution and LR_SHARED using the code above, then put it on a button and see the size (or see the size in a debugger).
This bug does not happen on windows.
https://bugs.winehq.org/show_bug.cgi?id=47076
Fabian Maurer dark.shadow4@web.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |dark.shadow4@web.de
https://bugs.winehq.org/show_bug.cgi?id=47076
--- Comment #1 from nikolaysemenkov@gmail.com --- I checked the code more and found the clear difference in behavior on wine and windows in LoadImage. On windows call to LoadImage with LR_SHARED having resolution 0,0 returns the icon bitmap of previous call to LoadImage with LR_SHARED having resolution NOT 0,0 ie: LoadImage(HInstance, MAKEINTRESOURCE(iIconLarge), IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR | LR_SHARED); LoadImage(HInstance, MAKEINTRESOURCE(iIconLarge), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR | LR_SHARED); HICON hIconTest = (HICON)LoadImage(HInstance, MAKEINTRESOURCE(iIconLarge), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_SHARED);
// Print the icon resolution: ICONINFO iconInfo; if (GetIconInfo(hIconTest, &iconInfo)) { BITMAP BMInf; GetObject(iconInfo.hbmColor, sizeof(BMInf), &BMInf); printf("xxxxxxxxxxxxxxx result: %d %d", BMInf.bmWidth, BMInf.bmHeight); }
Last call on windows returns the icon handle with sizes of 16x16 and on wine it is 32x32.
Even on windows result of LoadImage with LR_SHARED and resolution 0,0 looks unexpected because it returns the icon handle with bitmap of previously used resolution.
https://bugs.winehq.org/show_bug.cgi?id=47076
--- Comment #2 from nikolaysemenkov@gmail.com --- MediaInfo show following info for the icon: Image #1 Width : 16 pixels Height : 16 pixels Bit depth : 8 bits Stream size : 1.35 KiB (54%)
Image #2 Width : 16 pixels Height : 16 pixels Bit depth : 32 bits Stream size : 1.10 KiB (44%)
https://bugs.winehq.org/show_bug.cgi?id=47076
--- Comment #3 from nikolaysemenkov@gmail.com --- To be clear, below is the code to reproduce the bug. The icon details were specified in previous message. The code to see the bug:
LoadImage(HInstance, MAKEINTRESOURCE(iIconLarge), IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR | LR_SHARED); HICON hIconTest = (HICON)LoadImage(HInstance, MAKEINTRESOURCE(iIconLarge), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_SHARED);
// Get info ICONINFO iconInfo; if (GetIconInfo(hIconTest, &iconInfo)) { BITMAP BMInf; GetObject(iconInfo.hbmColor, sizeof(BMInf), &BMInf); printf("xxxxxxxxxxxxxxx result: %d %d", BMInf.bmWidth, BMInf.bmHeight); return;
}
On windows result for a 16x16 icon is 16x16. On wine the result is 32x32