- bits = lpbc->bcBitCount;
-
- switch (bits) {
- case 1:
- return 2;
- case 4:
- return 16;
- case 8:
- return 256;
- default:
- /* A 24 bitcount DIB has no color table */
- return 0;
- }
-}
-
-/****************************************************************************
- * *
- * FUNCTION : DibFromBitmap() *
- * *
- * PURPOSE : Will create a global memory block in DIB format that *
- * represents the Device-dependent bitmap (DDB) passed in. *
- * *
- * RETURNS : A handle to the DIB *
- * *
- ****************************************************************************/
-
-#if NOTHING
-static HANDLE DibFromBitmap(HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hpal)
-{
- BITMAP bm;
- BITMAPINFOHEADER bi;
- BITMAPINFOHEADER FAR *lpbi;
- DWORD dwLen;
- HANDLE hdib;
- HANDLE h;
- HDC hdc;
-
- if (!hbm)
- return NULL;
-
- if (hpal == NULL)
- hpal = GetStockObject(DEFAULT_PALETTE);
-
- GetObject(hbm, sizeof (bm), (LPSTR) &bm);
-
- if (biBits == 0)
- biBits = bm.bmPlanes * bm.bmBitsPixel;
-
- bi.biSize = sizeof(BITMAPINFOHEADER);
- bi.biWidth = bm.bmWidth;
- bi.biHeight = bm.bmHeight;
- bi.biPlanes = 1;
- bi.biBitCount = biBits;
- bi.biCompression = biStyle;
- bi.biSizeImage = 0;
- bi.biXPelsPerMeter = 0;
- bi.biYPelsPerMeter = 0;
- bi.biClrUsed = 0;
- bi.biClrImportant = 0;
-
- dwLen = bi.biSize + wxPaletteSize(&bi);
-
- hdc = GetDC((HWND) NULL);
- hpal = SelectPalette(hdc, hpal, FALSE);
- RealizePalette(hdc);
-
- hdib = GlobalAlloc(GHND, dwLen);
-
- if (!hdib) {
- SelectPalette(hdc, hpal, FALSE);
- ReleaseDC(NULL, hdc);
- return NULL;
- }
-
-#ifdef __WINDOWS_386__
- lpbi = (BITMAPINFOHEADER FAR *) MK_FP32(GlobalLock(hdib));
-#else
- lpbi = (BITMAPINFOHEADER FAR *) GlobalLock(hdib);
-#endif
-
- *lpbi = bi;
-
- /* call GetDIBits with a NULL lpBits param, so it will calculate the
- * biSizeImage field for us
- */
- GetDIBits(hdc, hbm, 0, (WORD) bi.biHeight,
- NULL, (LPBITMAPINFO) lpbi, DIB_RGB_COLORS);
-
- bi = *lpbi;
- GlobalUnlock(hdib);
-
- /* If the driver did not fill in the biSizeImage field, make one up */
- if (bi.biSizeImage == 0) {
- bi.biSizeImage = WIDTHBYTES((DWORD)bm.bmWidth * biBits) * bm.bmHeight;
-
- if (biStyle != BI_RGB)
- bi.biSizeImage = (bi.biSizeImage * 3) / 2;
- }