mirror of
https://github.com/reactos/reactos.git
synced 2024-09-29 14:09:10 +00:00
Workaround for icon stretching. Makes icons in title bar and taskbar display
properly. svn path=/trunk/; revision=18763
This commit is contained in:
parent
4b3bf39cbc
commit
cc33d0bac1
|
@ -1269,7 +1269,82 @@ NtUserSetSystemCursor(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define CANSTRETCHBLT 0
|
#define STRETCH_CAN_SRCCOPY_ONLY
|
||||||
|
|
||||||
|
#ifdef STRETCH_CAN_SRCCOPY_ONLY
|
||||||
|
void
|
||||||
|
FASTCALL
|
||||||
|
DoStretchBlt(HDC DcDest, int XDest, int YDest, int WidthDest, int HeightDest,
|
||||||
|
HDC DcSrc, int XSrc, int YSrc, int WidthSrc, int HeightSrc,
|
||||||
|
DWORD Rop3, BOOL Color)
|
||||||
|
{
|
||||||
|
HDC DcStretched;
|
||||||
|
HBITMAP BitmapStretched;
|
||||||
|
HBITMAP OldBitmap;
|
||||||
|
|
||||||
|
if (WidthDest == WidthSrc && HeightDest == HeightSrc)
|
||||||
|
{
|
||||||
|
NtGdiBitBlt(DcDest, XDest, YDest, WidthDest, HeightDest,
|
||||||
|
DcSrc, XSrc, YSrc, Rop3);
|
||||||
|
}
|
||||||
|
else if (SRCCOPY == Rop3)
|
||||||
|
{
|
||||||
|
NtGdiStretchBlt(DcDest, XDest, YDest, WidthDest, HeightDest,
|
||||||
|
DcSrc, XSrc, YSrc, WidthSrc, HeightSrc,
|
||||||
|
Rop3);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DcStretched = NtGdiCreateCompatibleDC(DcSrc);
|
||||||
|
if (NULL == DcStretched)
|
||||||
|
{
|
||||||
|
DPRINT1("Failed to create compatible DC\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Color)
|
||||||
|
{
|
||||||
|
BitmapStretched = NtGdiCreateCompatibleBitmap(DcDest, WidthDest,
|
||||||
|
HeightDest);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BitmapStretched = NtGdiCreateBitmap(WidthDest, HeightDest, 1, 1, NULL);
|
||||||
|
}
|
||||||
|
if (NULL == BitmapStretched)
|
||||||
|
{
|
||||||
|
NtGdiDeleteDC(DcStretched);
|
||||||
|
DPRINT1("Failed to create temporary bitmap\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
OldBitmap = NtGdiSelectObject(DcStretched, BitmapStretched);
|
||||||
|
if (NULL == OldBitmap)
|
||||||
|
{
|
||||||
|
NtGdiDeleteObject(BitmapStretched);
|
||||||
|
NtGdiDeleteDC(DcStretched);
|
||||||
|
DPRINT1("Failed to create temporary bitmap\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (! NtGdiStretchBlt(DcStretched, 0, 0, WidthDest, HeightDest,
|
||||||
|
DcSrc, XSrc, YSrc, WidthSrc, HeightSrc,
|
||||||
|
SRCCOPY) ||
|
||||||
|
! NtGdiBitBlt(DcDest, XDest, YDest, WidthDest, HeightDest,
|
||||||
|
DcStretched, 0, 0, Rop3))
|
||||||
|
{
|
||||||
|
DPRINT1("Failed to blt\n");
|
||||||
|
}
|
||||||
|
NtGdiSelectObject(DcStretched, OldBitmap);
|
||||||
|
NtGdiDeleteObject(BitmapStretched);
|
||||||
|
NtGdiDeleteDC(DcStretched);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define DoStretchBlt(DcDest, XDest, YDest, WidthDest, HeightDest, \
|
||||||
|
DcSrc, XSrc, YSrc, WidthSrc, HeightSrc, Rop3, Color) \
|
||||||
|
NtGdiStretchBlt((DcDest), (XDest), (YDest), (WidthDest), (HeightDest), \
|
||||||
|
(DcSrc), (XSrc), (YSrc), (WidthSrc), (HeightSrc), \
|
||||||
|
(Rop3))
|
||||||
|
#endif /* STRETCH_CAN_SRCCOPY_ONLY */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -1281,7 +1356,7 @@ NtUserDrawIconEx(
|
||||||
int yTop,
|
int yTop,
|
||||||
HICON hIcon,
|
HICON hIcon,
|
||||||
int cxWidth,
|
int cxWidth,
|
||||||
int cyWidth,
|
int cyHeight,
|
||||||
UINT istepIfAniCur,
|
UINT istepIfAniCur,
|
||||||
HBRUSH hbrFlickerFreeDraw,
|
HBRUSH hbrFlickerFreeDraw,
|
||||||
UINT diFlags,
|
UINT diFlags,
|
||||||
|
@ -1299,10 +1374,7 @@ NtUserDrawIconEx(
|
||||||
HBITMAP hbmOff = (HBITMAP)0;
|
HBITMAP hbmOff = (HBITMAP)0;
|
||||||
HGDIOBJ hOldOffBrush = 0, hOldOffBmp = 0, hOldMem;
|
HGDIOBJ hOldOffBrush = 0, hOldOffBmp = 0, hOldMem;
|
||||||
BOOL Ret = FALSE;
|
BOOL Ret = FALSE;
|
||||||
#if CANSTRETCHBLT
|
|
||||||
|
|
||||||
INT nStretchMode;
|
INT nStretchMode;
|
||||||
#endif
|
|
||||||
|
|
||||||
DECLARE_RETURN(BOOL);
|
DECLARE_RETURN(BOOL);
|
||||||
|
|
||||||
|
@ -1349,8 +1421,8 @@ NtUserDrawIconEx(
|
||||||
|
|
||||||
if(!cxWidth)
|
if(!cxWidth)
|
||||||
cxWidth = ((diFlags & DI_DEFAULTSIZE) ? UserGetSystemMetrics(SM_CXICON) : IconSize.cx);
|
cxWidth = ((diFlags & DI_DEFAULTSIZE) ? UserGetSystemMetrics(SM_CXICON) : IconSize.cx);
|
||||||
if(!cyWidth)
|
if(!cyHeight)
|
||||||
cyWidth = ((diFlags & DI_DEFAULTSIZE) ? UserGetSystemMetrics(SM_CYICON) : IconSize.cy);
|
cyHeight = ((diFlags & DI_DEFAULTSIZE) ? UserGetSystemMetrics(SM_CYICON) : IconSize.cy);
|
||||||
|
|
||||||
DoFlickerFree = (hbrFlickerFreeDraw && (NtGdiGetObjectType(hbrFlickerFreeDraw) == OBJ_BRUSH));
|
DoFlickerFree = (hbrFlickerFreeDraw && (NtGdiGetObjectType(hbrFlickerFreeDraw) == OBJ_BRUSH));
|
||||||
|
|
||||||
|
@ -1358,13 +1430,13 @@ NtUserDrawIconEx(
|
||||||
{
|
{
|
||||||
RECT r;
|
RECT r;
|
||||||
r.right = cxWidth;
|
r.right = cxWidth;
|
||||||
r.bottom = cyWidth;
|
r.bottom = cyHeight;
|
||||||
|
|
||||||
hdcOff = NtGdiCreateCompatibleDC(hdc);
|
hdcOff = NtGdiCreateCompatibleDC(hdc);
|
||||||
if(!hdcOff)
|
if(!hdcOff)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
hbmOff = NtGdiCreateCompatibleBitmap(hdc, cxWidth, cyWidth);
|
hbmOff = NtGdiCreateCompatibleBitmap(hdc, cxWidth, cyHeight);
|
||||||
if(!hbmOff)
|
if(!hbmOff)
|
||||||
{
|
{
|
||||||
NtGdiDeleteDC(hdcOff);
|
NtGdiDeleteDC(hdcOff);
|
||||||
|
@ -1383,10 +1455,7 @@ NtUserDrawIconEx(
|
||||||
if(!DoFlickerFree)
|
if(!DoFlickerFree)
|
||||||
hdcOff = hdc;
|
hdcOff = hdc;
|
||||||
|
|
||||||
#if CANSTRETCHBLT
|
|
||||||
|
|
||||||
nStretchMode = NtGdiSetStretchBltMode(hdcOff, STRETCH_DELETESCANS);
|
nStretchMode = NtGdiSetStretchBltMode(hdcOff, STRETCH_DELETESCANS);
|
||||||
#endif
|
|
||||||
|
|
||||||
oldFg = NtGdiSetTextColor(hdcOff, RGB(0, 0, 0));
|
oldFg = NtGdiSetTextColor(hdcOff, RGB(0, 0, 0));
|
||||||
oldBg = NtGdiSetBkColor(hdcOff, RGB(255, 255, 255));
|
oldBg = NtGdiSetBkColor(hdcOff, RGB(255, 255, 255));
|
||||||
|
@ -1394,27 +1463,18 @@ NtUserDrawIconEx(
|
||||||
if(diFlags & DI_MASK)
|
if(diFlags & DI_MASK)
|
||||||
{
|
{
|
||||||
hOldMem = NtGdiSelectObject(hdcMem, hbmMask);
|
hOldMem = NtGdiSelectObject(hdcMem, hbmMask);
|
||||||
#if CANSTRETCHBLT
|
|
||||||
|
|
||||||
NtGdiStretchBlt(hdcOff, (DoFlickerFree ? 0 : xLeft), (DoFlickerFree ? 0 : yTop),
|
DoStretchBlt(hdcOff, (DoFlickerFree ? 0 : xLeft),
|
||||||
cxWidth, cyWidth, hdcMem, 0, 0, IconSize.cx, IconSize.cy,
|
(DoFlickerFree ? 0 : yTop), cxWidth, cyHeight, hdcMem,
|
||||||
((diFlags & DI_IMAGE) ? SRCAND : SRCCOPY));
|
0, 0, IconSize.cx, IconSize.cy,
|
||||||
#else
|
((diFlags & DI_IMAGE) ? SRCAND : SRCCOPY), FALSE);
|
||||||
|
|
||||||
NtGdiBitBlt(hdcOff, (DoFlickerFree ? 0 : xLeft), (DoFlickerFree ? 0 : yTop),
|
|
||||||
cxWidth, cyWidth, hdcMem, 0, 0, ((diFlags & DI_IMAGE) ? SRCAND : SRCCOPY));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(!hbmColor && (bmpMask.bmHeight == 2 * bmpMask.bmWidth) && (diFlags & DI_IMAGE))
|
if(!hbmColor && (bmpMask.bmHeight == 2 * bmpMask.bmWidth) && (diFlags & DI_IMAGE))
|
||||||
{
|
{
|
||||||
#if CANSTRETCHBLT
|
DoStretchBlt(hdcOff, (DoFlickerFree ? 0 : xLeft),
|
||||||
NtGdiStretchBlt(hdcOff, (DoFlickerFree ? 0 : xLeft), (DoFlickerFree ? 0 : yTop),
|
(DoFlickerFree ? 0 : yTop), cxWidth, cyHeight, hdcMem,
|
||||||
cxWidth, cyWidth, hdcMem, 0, IconSize.cy, IconSize.cx, IconSize.cy, SRCINVERT);
|
0, IconSize.cy, IconSize.cx, IconSize.cy, SRCINVERT,
|
||||||
#else
|
FALSE);
|
||||||
|
|
||||||
NtGdiBitBlt(hdcOff, (DoFlickerFree ? 0 : xLeft), (DoFlickerFree ? 0 : yTop),
|
|
||||||
cxWidth, cyWidth, hdcMem, 0, IconSize.cy, SRCINVERT);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
diFlags &= ~DI_IMAGE;
|
diFlags &= ~DI_IMAGE;
|
||||||
}
|
}
|
||||||
|
@ -1424,30 +1484,23 @@ NtUserDrawIconEx(
|
||||||
if(diFlags & DI_IMAGE)
|
if(diFlags & DI_IMAGE)
|
||||||
{
|
{
|
||||||
hOldMem = NtGdiSelectObject(hdcMem, (hbmColor ? hbmColor : hbmMask));
|
hOldMem = NtGdiSelectObject(hdcMem, (hbmColor ? hbmColor : hbmMask));
|
||||||
#if CANSTRETCHBLT
|
|
||||||
|
|
||||||
NtGdiStretchBlt(hdcOff, (DoFlickerFree ? 0 : xLeft), (DoFlickerFree ? 0 : yTop),
|
DoStretchBlt(hdcOff, (DoFlickerFree ? 0 : xLeft),
|
||||||
cxWidth, cyWidth, hdcMem, 0, (hbmColor ? 0 : IconSize.cy),
|
(DoFlickerFree ? 0 : yTop), cxWidth, cyHeight, hdcMem,
|
||||||
IconSize.cx, IconSize.cy, ((diFlags & DI_MASK) ? SRCINVERT : SRCCOPY));
|
0, (hbmColor ? 0 : IconSize.cy), IconSize.cx, IconSize.cy,
|
||||||
#else
|
((diFlags & DI_MASK) ? SRCINVERT : SRCCOPY),
|
||||||
|
NULL != hbmColor);
|
||||||
NtGdiBitBlt(hdcOff, (DoFlickerFree ? 0 : xLeft), (DoFlickerFree ? 0 : yTop),
|
|
||||||
cxWidth, cyWidth, hdcMem, 0, (hbmColor ? 0 : IconSize.cy),
|
|
||||||
((diFlags & DI_MASK) ? SRCINVERT : SRCCOPY));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
NtGdiSelectObject(hdcMem, hOldMem);
|
NtGdiSelectObject(hdcMem, hOldMem);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(DoFlickerFree)
|
if(DoFlickerFree)
|
||||||
NtGdiBitBlt(hdc, xLeft, yTop, cxWidth, cyWidth, hdcOff, 0, 0, SRCCOPY);
|
NtGdiBitBlt(hdc, xLeft, yTop, cxWidth, cyHeight, hdcOff, 0, 0, SRCCOPY);
|
||||||
|
|
||||||
NtGdiSetTextColor(hdcOff, oldFg);
|
NtGdiSetTextColor(hdcOff, oldFg);
|
||||||
NtGdiSetBkColor(hdcOff, oldBg);
|
NtGdiSetBkColor(hdcOff, oldBg);
|
||||||
#if CANSTRETCHBLT
|
|
||||||
|
|
||||||
SetStretchBltMode(hdcOff, nStretchMode);
|
NtGdiSetStretchBltMode(hdcOff, nStretchMode);
|
||||||
#endif
|
|
||||||
|
|
||||||
Ret = TRUE;
|
Ret = TRUE;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue