In CreateDIBSection function, if hdc is NULL it now uses the desktop DC

instead of failing.
This commit is contained in:
Stephane Lussier 2000-07-11 22:04:44 +00:00 committed by Alexandre Julliard
parent a319a9784e
commit 23259ce5c9
1 changed files with 28 additions and 2 deletions

View File

@ -866,7 +866,17 @@ HBITMAP16 WINAPI CreateDIBSection16 (HDC16 hdc, BITMAPINFO *bmi, UINT16 usage,
DWORD offset)
{
HBITMAP16 hbitmap;
DC *dc = (DC *) GDI_GetObjPtr(hdc, DC_MAGIC);
DC *dc;
BOOL bDesktopDC = FALSE;
/* If the reference hdc is null, take the desktop dc */
if (hdc == 0)
{
hdc = CreateCompatibleDC(0);
bDesktopDC = TRUE;
}
dc = (DC *) GDI_GetObjPtr(hdc, DC_MAGIC);
if(!dc) dc = (DC *) GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
if(!dc) return (HBITMAP16) NULL;
@ -874,6 +884,9 @@ HBITMAP16 WINAPI CreateDIBSection16 (HDC16 hdc, BITMAPINFO *bmi, UINT16 usage,
GDI_HEAP_UNLOCK(hdc);
if (bDesktopDC)
DeleteDC(hdc);
return hbitmap;
}
@ -885,7 +898,17 @@ HBITMAP DIB_CreateDIBSection(HDC hdc, BITMAPINFO *bmi, UINT usage,
DWORD offset, DWORD ovr_pitch)
{
HBITMAP hbitmap;
DC *dc = (DC *) GDI_GetObjPtr(hdc, DC_MAGIC);
DC *dc;
BOOL bDesktopDC = FALSE;
/* If the reference hdc is null, take the desktop dc */
if (hdc == 0)
{
hdc = CreateCompatibleDC(0);
bDesktopDC = TRUE;
}
dc = (DC *) GDI_GetObjPtr(hdc, DC_MAGIC);
if(!dc) dc = (DC *) GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
if(!dc) return (HBITMAP) NULL;
@ -893,6 +916,9 @@ HBITMAP DIB_CreateDIBSection(HDC hdc, BITMAPINFO *bmi, UINT usage,
GDI_HEAP_UNLOCK(hdc);
if (bDesktopDC)
DeleteDC(hdc);
return hbitmap;
}