/* static */ HBITMAP wxDIB::ConvertToBitmap(const BITMAPINFO *pbmi, HDC hdc, void *bits) { wxCHECK_MSG( pbmi, 0, wxT("invalid DIB in ConvertToBitmap") ); // here we get BITMAPINFO struct followed by the actual bitmap bits and // BITMAPINFO starts with BITMAPINFOHEADER followed by colour info const BITMAPINFOHEADER *pbmih = &pbmi->bmiHeader; // get the pointer to the start of the real image data if we have a plain // DIB and not a DIB section (in the latter case the pointer must be passed // to us by the caller) if ( !bits ) { // we must skip over the colour table to get to the image data // // colour table either has the real colour data in which case its // number of entries is given by biClrUsed or is used for masks to be // used for extracting colour information from true colour bitmaps in // which case it always have exactly 3 DWORDs int numColors; switch ( pbmih->biCompression ) { case BI_BITFIELDS: numColors = 3; break; case BI_RGB: // biClrUsed has the number of colors but it may be not initialized at // all numColors = pbmih->biClrUsed; if ( !numColors ) { numColors = GetNumberOfColours(pbmih->biBitCount); } break; default: // no idea how it should be calculated for the other cases numColors = 0; } bits = (char *)pbmih + sizeof(*pbmih) + numColors*sizeof(RGBQUAD); } HBITMAP hbmp = ::CreateDIBitmap ( hdc ? hdc // create bitmap compatible : (HDC) ScreenHDC(), // with this DC pbmih, // used to get size &c CBM_INIT, // initialize bitmap bits too bits, // ... using this data pbmi, // this is used for palette only DIB_RGB_COLORS // direct or indexed palette? ); if ( !hbmp ) { wxLogLastError(wxT("CreateDIBitmap")); } return hbmp; }
/* static */ bool wxGLCanvasBase::IsDisplaySupported(const int *attribList) { // We need a device context to test the pixel format, so get one // for the root window. return wxGLCanvas::ChooseMatchingPixelFormat(ScreenHDC(), attribList) > 0; }