- success = ::BitBlt(GetHdc(), xdest, ydest,
- (int)width, (int)height,
- GetHdcOf(*source), xsrc, ysrc, dwRop) != 0;
+ // if we already have a DIB, draw it using StretchDIBits(), otherwise
+ // use StretchBlt() if available and finally fall back to BitBlt()
+
+ // FIXME: use appropriate WinCE functions
+#ifndef __WXWINCE__
+ const int caps = ::GetDeviceCaps(GetHdc(), RASTERCAPS);
+ if ( bmpSrc.Ok() && (caps & RC_STRETCHDIB) )
+ {
+ DIBSECTION ds;
+ wxZeroMemory(ds);
+
+ if ( ::GetObject(GetHbitmapOf(bmpSrc),
+ sizeof(ds),
+ &ds) == sizeof(ds) )
+ {
+ StretchBltModeChanger changeMode(GetHdc(), COLORONCOLOR);
+
+ // Figure out what co-ordinate system we're supposed to specify
+ // ysrc in.
+ const LONG hDIB = ds.dsBmih.biHeight;
+ if ( hDIB > 0 )
+ {
+ // reflect ysrc
+ ysrc = hDIB - (ysrc + height);
+ }
+
+ if ( ::StretchDIBits(GetHdc(),
+ xdest, ydest,
+ width, height,
+ xsrc, ysrc,
+ width, height,
+ ds.dsBm.bmBits,
+ (LPBITMAPINFO)&ds.dsBmih,
+ DIB_RGB_COLORS,
+ SRCCOPY
+ ) == (int)GDI_ERROR )
+ {
+ // On Win9x this API fails most (all?) of the time, so
+ // logging it becomes quite distracting. Since it falls
+ // back to the code below this is not really serious, so
+ // don't log it.
+ //wxLogLastError(wxT("StretchDIBits"));
+ }
+ else
+ {
+ success = true;
+ }
+ }
+ }
+
+ if ( !success && (caps & RC_STRETCHBLT) )
+#endif
+ // __WXWINCE__
+ {
+#ifndef __WXWINCE__
+ StretchBltModeChanger changeMode(GetHdc(), COLORONCOLOR);
+#endif
+
+ if ( !::StretchBlt
+ (
+ GetHdc(),
+ xdest, ydest, width, height,
+ GetHdcOf(*source),
+ xsrc, ysrc, width, height,
+ dwRop
+ ) )
+ {
+ wxLogLastError(_T("StretchBlt"));
+ }
+ else
+ {
+ success = true;
+ }
+ }
+