@@ -157,14 +157,14 @@ namespace Win32Utils
157157 }
158158 #endif
159159
160- HBITMAP CreateBitmap (int biWidth, int biHeight, UINT biPlanes, UINT biBitCount , HDC hDc)
160+ HBITMAP CreateBitmapWithAlphaChannel (int biWidth, int biHeight, HDC hDc)
161161 {
162162 BITMAPINFO bmi;
163163 bmi.bmiHeader .biSize = sizeof (BITMAPINFOHEADER);
164164 bmi.bmiHeader .biWidth = biWidth;
165165 bmi.bmiHeader .biHeight = biHeight;
166- bmi.bmiHeader .biPlanes = biPlanes ;
167- bmi.bmiHeader .biBitCount = biBitCount ;
166+ bmi.bmiHeader .biPlanes = 1 ;
167+ bmi.bmiHeader .biBitCount = 32 ;
168168 bmi.bmiHeader .biCompression = BI_RGB;
169169 bmi.bmiHeader .biSizeImage = biWidth * biHeight * 4 ;
170170 VOID* pvBits;
@@ -204,11 +204,11 @@ namespace Win32Utils
204204 return NULL ;
205205
206206 HWND hWndDesktop = GetDesktopWindow ();
207- HDC hdcDesktop = GetDC (hWndDesktop);
208- HDC hDcMem = CreateCompatibleDC (hdcDesktop );
207+ HDC hDcDesktop = GetDC (hWndDesktop);
208+ HDC hDcMem = CreateCompatibleDC (hDcDesktop );
209209
210210 // Create a 32bbp bitmap and select it.
211- HBITMAP hBitmap = CreateBitmap (bitmap_width, bitmap_height, 1 , BITS_PER_PIXEL , hDcMem);
211+ HBITMAP hBitmap = CreateBitmapWithAlphaChannel (bitmap_width, bitmap_height, hDcMem);
212212 HBITMAP hbmOld = (HBITMAP)SelectObject (hDcMem, hBitmap);
213213
214214 #if 0
@@ -280,7 +280,7 @@ namespace Win32Utils
280280 // Clean up.
281281 SelectObject (hDcMem, hbmOld);
282282 DeleteDC (hDcMem);
283- ReleaseDC (hWndDesktop, hdcDesktop );
283+ ReleaseDC (hWndDesktop, hDcDesktop );
284284
285285 return hBitmap;
286286 }
0 commit comments