Commit 159145ce authored by Alexandre Julliard's avatar Alexandre Julliard

user32: Make DrawIcon simply call DrawIconEx.

parent 4c03fd01
...@@ -1656,88 +1656,7 @@ static void premultiply_alpha_channel( unsigned char *destBitmap, ...@@ -1656,88 +1656,7 @@ static void premultiply_alpha_channel( unsigned char *destBitmap,
*/ */
BOOL WINAPI DrawIcon( HDC hdc, INT x, INT y, HICON hIcon ) BOOL WINAPI DrawIcon( HDC hdc, INT x, INT y, HICON hIcon )
{ {
CURSORICONINFO *ptr; return DrawIconEx( hdc, x, y, hIcon, 0, 0, 0, 0, DI_NORMAL | DI_COMPAT | DI_DEFAULTSIZE );
HDC hMemDC;
HBITMAP hXorBits = NULL, hAndBits = NULL, hBitTemp = NULL;
COLORREF oldFg, oldBg;
unsigned char *xorBitmapBits;
unsigned int dibLength;
TRACE("%p, (%d,%d), %p\n", hdc, x, y, hIcon);
if (!(ptr = get_icon_ptr( hIcon ))) return FALSE;
if (!(hMemDC = CreateCompatibleDC( hdc )))
{
release_icon_ptr( hIcon, ptr );
return FALSE;
}
dibLength = ptr->nHeight * get_bitmap_width_bytes(
ptr->nWidth, ptr->bBitsPerPixel);
xorBitmapBits = (unsigned char *)(ptr + 1) + ptr->nHeight *
get_bitmap_width_bytes(ptr->nWidth, 1);
oldFg = SetTextColor( hdc, RGB(0,0,0) );
oldBg = SetBkColor( hdc, RGB(255,255,255) );
if(bitmap_has_alpha_channel(ptr->bBitsPerPixel, xorBitmapBits, dibLength))
{
BITMAPINFOHEADER bmih;
unsigned char *dibBits;
memset(&bmih, 0, sizeof(BITMAPINFOHEADER));
bmih.biSize = sizeof(BITMAPINFOHEADER);
bmih.biWidth = ptr->nWidth;
bmih.biHeight = -ptr->nHeight;
bmih.biPlanes = ptr->bPlanes;
bmih.biBitCount = 32;
bmih.biCompression = BI_RGB;
hXorBits = CreateDIBSection(hdc, (BITMAPINFO*)&bmih, DIB_RGB_COLORS,
(void*)&dibBits, NULL, 0);
if (hXorBits && dibBits)
{
BLENDFUNCTION pixelblend = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
/* Do the alpha blending render */
premultiply_alpha_channel(dibBits, xorBitmapBits, dibLength);
hBitTemp = SelectObject( hMemDC, hXorBits );
/* Destination width/height has to be "System Large" size */
GdiAlphaBlend(hdc, x, y, GetSystemMetrics(SM_CXICON),
GetSystemMetrics(SM_CYICON), hMemDC,
0, 0, ptr->nWidth, ptr->nHeight, pixelblend);
SelectObject( hMemDC, hBitTemp );
}
}
else
{
hAndBits = CreateBitmap( ptr->nWidth, ptr->nHeight, 1, 1, ptr + 1 );
hXorBits = CreateBitmap( ptr->nWidth, ptr->nHeight, ptr->bPlanes,
ptr->bBitsPerPixel, xorBitmapBits);
if (hXorBits && hAndBits)
{
hBitTemp = SelectObject( hMemDC, hAndBits );
StretchBlt( hdc, x, y, GetSystemMetrics(SM_CXICON),
GetSystemMetrics(SM_CYICON), hMemDC, 0, 0,
ptr->nWidth, ptr->nHeight, SRCAND );
SelectObject( hMemDC, hXorBits );
StretchBlt( hdc, x, y, GetSystemMetrics(SM_CXICON),
GetSystemMetrics(SM_CYICON), hMemDC, 0, 0,
ptr->nWidth, ptr->nHeight, SRCINVERT );
SelectObject( hMemDC, hBitTemp );
}
}
DeleteDC( hMemDC );
if (hXorBits) DeleteObject( hXorBits );
if (hAndBits) DeleteObject( hAndBits );
release_icon_ptr( hIcon, ptr );
SetTextColor( hdc, oldFg );
SetBkColor( hdc, oldBg );
return TRUE;
} }
/*********************************************************************** /***********************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment