void *color_bits, *mask_bits;
BOOL ret = FALSE;
HDC hdc = 0;
+ static HDC hScreenDC = 0;
if (!(info = HeapAlloc( GetProcessHeap(), 0, max( size, FIELD_OFFSET( BITMAPINFO, bmiColors[2] )))))
return FALSE;
- if (!(hdc = CreateCompatibleDC( 0 ))) goto done;
+ if(!hScreenDC)
+ {
+ hScreenDC = GetDC(0);
+ if(!hScreenDC) goto done;
+ }
+ if (!(hdc = CreateCompatibleDC(hScreenDC))) goto done;
memcpy( info, bmi, size );
info->bmiHeader.biHeight /= 2;
else
{
if (!(*mask = CreateBitmap( width, height, 1, 1, NULL ))) goto done;
- if (!(*color = CreateBitmap( width, height, bmi->bmiHeader.biPlanes,
- bmi->bmiHeader.biBitCount, NULL )))
+ if (!(*color = CreateBitmap( width, height, GetDeviceCaps(hScreenDC, PLANES),
+ GetDeviceCaps(hScreenDC, BITSPIXEL), NULL )))
{
DeleteObject( *mask );
goto done;
ret = TRUE;
done:
- DeleteDC( hdc );
+ if(hdc) DeleteDC( hdc );
HeapFree( GetProcessHeap(), 0, info );
return ret;
}