user32: Restore special handling of monochrome bitmaps removed by c2202929ab4b6d1ce379865dfd8904186814f265.

This commit is contained in:
Dmitry Timoshkov 2010-03-11 16:22:33 +08:00 committed by Alexandre Julliard
parent 8447844d81
commit 52ebbb8aa7

View File

@ -765,6 +765,7 @@ static HICON CURSORICON_CreateIconFromBMI( BITMAPINFO *bmi,
int sizeAnd, sizeXor; int sizeAnd, sizeXor;
HBITMAP hAndBits = 0, hXorBits = 0; /* error condition for later */ HBITMAP hAndBits = 0, hXorBits = 0; /* error condition for later */
BITMAP bmpXor, bmpAnd; BITMAP bmpXor, bmpAnd;
BOOL do_stretch;
INT size; INT size;
BITMAPINFO *pSrcInfo, *pDestInfo; BITMAPINFO *pSrcInfo, *pDestInfo;
@ -788,10 +789,11 @@ static HICON CURSORICON_CreateIconFromBMI( BITMAPINFO *bmi,
if (!width) width = bmi->bmiHeader.biWidth; if (!width) width = bmi->bmiHeader.biWidth;
if (!height) height = bmi->bmiHeader.biHeight/2; if (!height) height = bmi->bmiHeader.biHeight/2;
do_stretch = (bmi->bmiHeader.biHeight/2 != height) ||
(bmi->bmiHeader.biWidth != width);
/* Scale the hotspot */ /* Scale the hotspot */
if (((bmi->bmiHeader.biHeight/2 != height) || (bmi->bmiHeader.biWidth != width)) && if (do_stretch && hotspot.x != ICON_HOTSPOT && hotspot.y != ICON_HOTSPOT)
hotspot.x != ICON_HOTSPOT && hotspot.y != ICON_HOTSPOT)
{ {
hotspot.x = (hotspot.x * width) / bmi->bmiHeader.biWidth; hotspot.x = (hotspot.x * width) / bmi->bmiHeader.biWidth;
hotspot.y = (hotspot.y * height) / (bmi->bmiHeader.biHeight / 2); hotspot.y = (hotspot.y * height) / (bmi->bmiHeader.biHeight / 2);
@ -842,16 +844,30 @@ static HICON CURSORICON_CreateIconFromBMI( BITMAPINFO *bmi,
} }
else else
{ {
hXorBits = CreateCompatibleBitmap(screen_dc, width, height); if (do_stretch)
if(hXorBits)
{ {
if(!stretch_blt_icon(hXorBits, pDestInfo, pSrcInfo, (char*)bmi + size)) hXorBits = CreateCompatibleBitmap(screen_dc, width, height);
if (hXorBits)
{ {
DeleteObject(hXorBits); if (!stretch_blt_icon(hXorBits, pDestInfo, pSrcInfo, (char*)bmi + size))
hXorBits = 0; {
DeleteObject(hXorBits);
hXorBits = 0;
}
} }
} }
else
{
if (is_dib_monochrome(bmi))
{
hXorBits = CreateBitmap(width, height, 1, 1, NULL);
SetDIBits(screen_dc, hXorBits, 0, height,
(char *)bmi + size, pSrcInfo, DIB_RGB_COLORS);
}
else
hXorBits = CreateDIBitmap(screen_dc, &pSrcInfo->bmiHeader,
CBM_INIT, (char *)bmi + size, pSrcInfo, DIB_RGB_COLORS);
}
} }
if( hXorBits ) if( hXorBits )
@ -879,12 +895,21 @@ static HICON CURSORICON_CreateIconFromBMI( BITMAPINFO *bmi,
} }
/* Create the AND bitmap */ /* Create the AND bitmap */
hAndBits = CreateBitmap(width, height, 1, 1, NULL); if (do_stretch)
if(!stretch_blt_icon(hAndBits, pDestInfo, pSrcInfo, xbits))
{ {
DeleteObject(hAndBits); hAndBits = CreateBitmap(width, height, 1, 1, NULL);
hAndBits = 0;
if (!stretch_blt_icon(hAndBits, pDestInfo, pSrcInfo, xbits))
{
DeleteObject(hAndBits);
hAndBits = 0;
}
}
else
{
hAndBits = CreateBitmap(width, height, 1, 1, NULL);
SetDIBits(screen_dc, hAndBits, 0, height,
xbits, pSrcInfo, DIB_RGB_COLORS);
} }
if( !hAndBits ) if( !hAndBits )