mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 14:50:48 +00:00
user32: Fix LoadImage behavior with zero size and no LR_DEFAULTSIZE.
Based on a patch by Marcus Meissner.
This commit is contained in:
parent
ab4a5a327d
commit
76fb69bf3d
1 changed files with 36 additions and 12 deletions
|
@ -422,7 +422,20 @@ static int CURSORICON_FindBestIcon( LPCVOID dir, fnGetCIEntry get_entry,
|
|||
/* Find Best Fit */
|
||||
iTotalDiff = 0xFFFFFFFF;
|
||||
iColorDiff = 0xFFFFFFFF;
|
||||
for ( i = 0; get_entry( dir, i, &cx, &cy, &bits ); i++ )
|
||||
|
||||
if (loadflags & LR_DEFAULTSIZE)
|
||||
{
|
||||
if (!width) width = GetSystemMetrics( SM_CXICON );
|
||||
if (!height) height = GetSystemMetrics( SM_CYICON );
|
||||
}
|
||||
else if (!width && !height)
|
||||
{
|
||||
/* use the size of the first entry */
|
||||
if (!get_entry( dir, 0, &width, &height, &bits )) return -1;
|
||||
iTotalDiff = 0;
|
||||
}
|
||||
|
||||
for ( i = 0; iTotalDiff && get_entry( dir, i, &cx, &cy, &bits ); i++ )
|
||||
{
|
||||
iTempXDiff = abs(width - cx);
|
||||
iTempYDiff = abs(height - cy);
|
||||
|
@ -479,6 +492,18 @@ static int CURSORICON_FindBestCursor( LPCVOID dir, fnGetCIEntry get_entry,
|
|||
{
|
||||
int i, maxwidth, maxheight, cx, cy, bits, bestEntry = -1;
|
||||
|
||||
if (loadflags & LR_DEFAULTSIZE)
|
||||
{
|
||||
if (!width) width = GetSystemMetrics( SM_CXCURSOR );
|
||||
if (!height) height = GetSystemMetrics( SM_CYCURSOR );
|
||||
}
|
||||
else if (!width && !height)
|
||||
{
|
||||
/* use the first entry */
|
||||
if (!get_entry( dir, 0, &width, &height, &bits )) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Double height to account for AND and XOR masks */
|
||||
|
||||
height *= 2;
|
||||
|
@ -782,8 +807,16 @@ static HICON CURSORICON_CreateIconFromBMI( BITMAPINFO *bmi, HMODULE module, LPCW
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (!width) width = bmi->bmiHeader.biWidth;
|
||||
if (!height) height = bmi->bmiHeader.biHeight/2;
|
||||
if (cFlag & LR_DEFAULTSIZE)
|
||||
{
|
||||
if (!width) width = GetSystemMetrics( bIcon ? SM_CXICON : SM_CXCURSOR );
|
||||
if (!height) height = GetSystemMetrics( bIcon ? SM_CYICON : SM_CYCURSOR );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!width) width = bmi->bmiHeader.biWidth;
|
||||
if (!height) height = bmi->bmiHeader.biHeight/2;
|
||||
}
|
||||
do_stretch = (bmi->bmiHeader.biHeight/2 != height) ||
|
||||
(bmi->bmiHeader.biWidth != width);
|
||||
|
||||
|
@ -2274,15 +2307,6 @@ HANDLE WINAPI LoadImageW( HINSTANCE hinst, LPCWSTR name, UINT type,
|
|||
TRACE_(resource)("(%p,%s,%d,%d,%d,0x%08x)\n",
|
||||
hinst,debugstr_w(name),type,desiredx,desiredy,loadflags);
|
||||
|
||||
if (loadflags & LR_DEFAULTSIZE) {
|
||||
if (type == IMAGE_ICON) {
|
||||
if (!desiredx) desiredx = GetSystemMetrics(SM_CXICON);
|
||||
if (!desiredy) desiredy = GetSystemMetrics(SM_CYICON);
|
||||
} else if (type == IMAGE_CURSOR) {
|
||||
if (!desiredx) desiredx = GetSystemMetrics(SM_CXCURSOR);
|
||||
if (!desiredy) desiredy = GetSystemMetrics(SM_CYCURSOR);
|
||||
}
|
||||
}
|
||||
if (loadflags & LR_LOADFROMFILE) loadflags &= ~LR_SHARED;
|
||||
switch (type) {
|
||||
case IMAGE_BITMAP:
|
||||
|
|
Loading…
Reference in a new issue