+ // how many colours are we going to have in the palette?
+ DWORD biClrUsed = ds.dsBmih.biClrUsed;
+ if ( !biClrUsed )
+ {
+ // biClrUsed field might not be set
+ biClrUsed = GetNumberOfColours(ds.dsBmih.biBitCount);
+ }
+
+ if ( !biClrUsed )
+ {
+ return ConvertToBitmap((BITMAPINFO *)&ds.dsBmih, hdc, ds.dsBm.bmBits);
+ }
+ else
+ {
+ // fake a BITMAPINFO w/o bits, just the palette info
+ wxCharBuffer bmi(sizeof(BITMAPINFO) + (biClrUsed - 1)*sizeof(RGBQUAD));
+ BITMAPINFO *pBmi = (BITMAPINFO *)bmi.data();
+ MemoryHDC hDC;
+ // get the colour table
+ SelectInHDC sDC(hDC, m_handle);
+ ::GetDIBColorTable(hDC, 0, biClrUsed, pBmi->bmiColors);
+ memcpy(&pBmi->bmiHeader, &ds.dsBmih, ds.dsBmih.biSize);
+
+ return ConvertToBitmap(pBmi, hdc, ds.dsBm.bmBits);
+ }