mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
Evgeniy Boltik <bstsoft AT narod DOT ru>
- Fix draw icon with alpha in 32 bit. - See issue #4243 for details. svn path=/trunk/; revision=39989
This commit is contained in:
parent
004cc56ed5
commit
f7a722ebda
1 changed files with 29 additions and 85 deletions
|
@ -1389,82 +1389,6 @@ NtUserSetSystemCursor(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#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, 0, 0);
|
|
||||||
}
|
|
||||||
else if (SRCCOPY == Rop3)
|
|
||||||
{
|
|
||||||
NtGdiStretchBlt(DcDest, XDest, YDest, WidthDest, HeightDest,
|
|
||||||
DcSrc, XSrc, YSrc, WidthSrc, HeightSrc,
|
|
||||||
Rop3, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DcStretched = NtGdiCreateCompatibleDC(DcSrc);
|
|
||||||
if (NULL == DcStretched)
|
|
||||||
{
|
|
||||||
DPRINT1("Failed to create compatible DC\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (Color)
|
|
||||||
{
|
|
||||||
BitmapStretched = NtGdiCreateCompatibleBitmap(DcDest, WidthDest,
|
|
||||||
HeightDest);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BitmapStretched = IntGdiCreateBitmap(WidthDest, HeightDest, 1, 1, NULL);
|
|
||||||
}
|
|
||||||
if (NULL == BitmapStretched)
|
|
||||||
{
|
|
||||||
NtGdiDeleteObjectApp(DcStretched);
|
|
||||||
DPRINT1("Failed to create temporary bitmap\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
OldBitmap = NtGdiSelectBitmap(DcStretched, BitmapStretched);
|
|
||||||
if (NULL == OldBitmap)
|
|
||||||
{
|
|
||||||
NtGdiDeleteObject(BitmapStretched);
|
|
||||||
NtGdiDeleteObjectApp(DcStretched);
|
|
||||||
DPRINT1("Failed to create temporary bitmap\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (! NtGdiStretchBlt(DcStretched, 0, 0, WidthDest, HeightDest,
|
|
||||||
DcSrc, XSrc, YSrc, WidthSrc, HeightSrc,
|
|
||||||
SRCCOPY, 0) ||
|
|
||||||
! NtGdiBitBlt(DcDest, XDest, YDest, WidthDest, HeightDest,
|
|
||||||
DcStretched, 0, 0, Rop3, 0, 0))
|
|
||||||
{
|
|
||||||
DPRINT1("Failed to blt\n");
|
|
||||||
}
|
|
||||||
NtGdiSelectBitmap(DcStretched, OldBitmap);
|
|
||||||
NtGdiDeleteObject(BitmapStretched);
|
|
||||||
NtGdiDeleteObjectApp(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), 0)
|
|
||||||
#endif /* STRETCH_CAN_SRCCOPY_ONLY */
|
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
UserDrawIconEx(
|
UserDrawIconEx(
|
||||||
HDC hDc,
|
HDC hDc,
|
||||||
|
@ -1482,7 +1406,6 @@ UserDrawIconEx(
|
||||||
BITMAP bmpMask, bmpColor;
|
BITMAP bmpMask, bmpColor;
|
||||||
COLORREF oldFg, oldBg;
|
COLORREF oldFg, oldBg;
|
||||||
BOOL DoFlickerFree;
|
BOOL DoFlickerFree;
|
||||||
INT nStretchMode;
|
|
||||||
SIZE IconSize;
|
SIZE IconSize;
|
||||||
|
|
||||||
HDC hdcOff;
|
HDC hdcOff;
|
||||||
|
@ -1524,7 +1447,31 @@ UserDrawIconEx(
|
||||||
when cxWidth or cyHeight is 0 */
|
when cxWidth or cyHeight is 0 */
|
||||||
if ((bmpColor.bmBitsPixel == 32) && (cxWidth != 0) && (cyHeight != 0))
|
if ((bmpColor.bmBitsPixel == 32) && (cxWidth != 0) && (cyHeight != 0))
|
||||||
{
|
{
|
||||||
bAlpha = TRUE;
|
SURFACE *psurfOff = NULL;
|
||||||
|
PFN_DIB_GetPixel fnSource_GetPixel = NULL;
|
||||||
|
INT x, y;
|
||||||
|
|
||||||
|
//Find alpha into icon
|
||||||
|
psurfOff = SURFACE_LockSurface(hbmColor ? hbmColor : hbmMask);
|
||||||
|
if (psurfOff)
|
||||||
|
{
|
||||||
|
fnSource_GetPixel = DibFunctionsForBitmapFormat[psurfOff->SurfObj.iBitmapFormat].DIB_GetPixel;
|
||||||
|
if (fnSource_GetPixel)
|
||||||
|
{
|
||||||
|
for (x = 0; x < psurfOff->SurfObj.sizlBitmap.cx; x++)
|
||||||
|
{
|
||||||
|
for (y = 0; y < psurfOff->SurfObj.sizlBitmap.cy; y++)
|
||||||
|
{
|
||||||
|
bAlpha = ((BYTE)(fnSource_GetPixel(&psurfOff->SurfObj, x, y) >> 24) & 0xff);
|
||||||
|
if (bAlpha)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (bAlpha)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SURFACE_UnlockSurface(psurfOff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!diFlags)
|
if (!diFlags)
|
||||||
|
@ -1608,8 +1555,6 @@ UserDrawIconEx(
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
nStretchMode = IntGdiSetStretchBltMode(hdcOff, STRETCH_DELETESCANS);
|
|
||||||
|
|
||||||
oldFg = IntGdiSetTextColor(hdcOff, RGB(0, 0, 0));
|
oldFg = IntGdiSetTextColor(hdcOff, RGB(0, 0, 0));
|
||||||
oldBg = IntGdiSetBkColor(hdcOff, RGB(255, 255, 255));
|
oldBg = IntGdiSetBkColor(hdcOff, RGB(255, 255, 255));
|
||||||
|
|
||||||
|
@ -1622,7 +1567,7 @@ UserDrawIconEx(
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
DoStretchBlt(hdcOff,
|
NtGdiStretchBlt(hdcOff,
|
||||||
(DoFlickerFree || bAlpha ? 0 : xLeft),
|
(DoFlickerFree || bAlpha ? 0 : xLeft),
|
||||||
(DoFlickerFree || bAlpha ? 0 : yTop),
|
(DoFlickerFree || bAlpha ? 0 : yTop),
|
||||||
cxWidth,
|
cxWidth,
|
||||||
|
@ -1633,7 +1578,7 @@ UserDrawIconEx(
|
||||||
IconSize.cx,
|
IconSize.cx,
|
||||||
IconSize.cy,
|
IconSize.cy,
|
||||||
((diFlags & DI_IMAGE) ? SRCAND : SRCCOPY),
|
((diFlags & DI_IMAGE) ? SRCAND : SRCCOPY),
|
||||||
FALSE);
|
0);
|
||||||
|
|
||||||
NtGdiSelectBitmap(hdcMem, hOldMem);
|
NtGdiSelectBitmap(hdcMem, hOldMem);
|
||||||
}
|
}
|
||||||
|
@ -1642,7 +1587,7 @@ UserDrawIconEx(
|
||||||
{
|
{
|
||||||
hOldMem = NtGdiSelectBitmap(hdcMem, (hbmColor ? hbmColor : hbmMask));
|
hOldMem = NtGdiSelectBitmap(hdcMem, (hbmColor ? hbmColor : hbmMask));
|
||||||
|
|
||||||
DoStretchBlt(hdcOff,
|
NtGdiStretchBlt(hdcOff,
|
||||||
(DoFlickerFree || bAlpha ? 0 : xLeft),
|
(DoFlickerFree || bAlpha ? 0 : xLeft),
|
||||||
(DoFlickerFree || bAlpha ? 0 : yTop),
|
(DoFlickerFree || bAlpha ? 0 : yTop),
|
||||||
cxWidth,
|
cxWidth,
|
||||||
|
@ -1653,7 +1598,7 @@ UserDrawIconEx(
|
||||||
IconSize.cx,
|
IconSize.cx,
|
||||||
IconSize.cy,
|
IconSize.cy,
|
||||||
((diFlags & DI_MASK) ? SRCINVERT : SRCCOPY),
|
((diFlags & DI_MASK) ? SRCINVERT : SRCCOPY),
|
||||||
NULL != hbmColor);
|
0);
|
||||||
|
|
||||||
NtGdiSelectBitmap(hdcMem, hOldMem);
|
NtGdiSelectBitmap(hdcMem, hOldMem);
|
||||||
}
|
}
|
||||||
|
@ -1729,7 +1674,6 @@ UserDrawIconEx(
|
||||||
|
|
||||||
IntGdiSetTextColor(hdcOff, oldFg);
|
IntGdiSetTextColor(hdcOff, oldFg);
|
||||||
IntGdiSetBkColor(hdcOff, oldBg);
|
IntGdiSetBkColor(hdcOff, oldBg);
|
||||||
IntGdiSetStretchBltMode(hdcOff, nStretchMode);
|
|
||||||
|
|
||||||
Ret = TRUE;
|
Ret = TRUE;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue