- if ( ::GetDeviceCaps(GetHdc(), RASTERCAPS) & RC_STRETCHDIB )
- {
-#if wxUSE_DIB_FOR_BITMAP
- if ( bmp.IsDIB() )
- {
- DIBSECTION dib;
- if ( ::GetObject(GetHbitmapOf(bmp),
- sizeof(dib),
- &dib) == sizeof(dib) )
- {
- if ( ::StretchDIBits
- (
- GetHdc(),
- x, y,
- width, height,
- 0, 0,
- width, height,
- dib.dsBm.bmBits,
- (LPBITMAPINFO)&dib.dsBmih,
- DIB_RGB_COLORS,
- SRCCOPY
- ) == GDI_ERROR )
- {
- wxLogLastError(wxT("StretchDIBits"));
- }
- }
- else
- {
- wxLogLastError(wxT("GetObject"));
- }
- }
- else
-#endif // wxUSE_DIB_FOR_BITMAP
- {
- BITMAPINFO *info = (BITMAPINFO *) malloc( sizeof( BITMAPINFOHEADER ) + 256 * sizeof(RGBQUAD ) );
- memset( info, 0, sizeof( BITMAPINFOHEADER ) );
-
-#if wxUSE_DRAWBITMAP_24BITS
- int iBitsSize = (((width * 3) + 3 ) & ~3 ) * height;
-#else
- int iBitsSize = ((width + 3 ) & ~3 ) * height ;
-#endif
-
- void* bits = malloc( iBitsSize );
-
- info->bmiHeader.biSize = sizeof( BITMAPINFOHEADER );
- info->bmiHeader.biWidth = width;
- info->bmiHeader.biHeight = height;
- info->bmiHeader.biPlanes = 1;
-#if wxUSE_DRAWBITMAP_24BITS
- info->bmiHeader.biBitCount = 24;
-#else
- info->bmiHeader.biBitCount = 8;
-#endif
- info->bmiHeader.biCompression = BI_RGB;
-
- ScreenHDC display;
- if ( GetDIBits(display, GetHbitmapOf(bmp), 0,
- bmp.GetHeight(), bits, info,
- DIB_RGB_COLORS) )
- {
- if ( ::StretchDIBits(GetHdc(), x, y,
- width, height,
- 0 , 0, width, height,
- bits, info,
- DIB_RGB_COLORS, SRCCOPY) == GDI_ERROR )
- {
- wxLogLastError(wxT("StretchDIBits"));
- }
- }
-
- free(bits);
- free(info);
- }
- }
- else // no support for StretchDIBits()