if (!GetHDC()) return FALSE;
#endif
+ const wxBitmap& bmpSrc = source->m_selectedBitmap;
+
wxMask *mask = NULL;
if ( useMask )
{
- const wxBitmap& bmp = source->m_selectedBitmap;
- mask = bmp.GetMask();
+ mask = bmpSrc.GetMask();
- if ( !(bmp.Ok() && mask && mask->GetMaskBitmap()) )
+ if ( !(bmpSrc.Ok() && mask && mask->GetMaskBitmap()) )
{
// don't give assert here because this would break existing
// programs - just silently ignore useMask parameter
}
else // no mask, just BitBlt() it
{
- // use StretchBlt() if available
- if ( ::GetDeviceCaps(GetHdc(), RASTERCAPS) & RC_STRETCHBLT )
+ // if we already have a DIB, draw it using StretchDIBits(), otherwise
+ // use StretchBlt() if available and finally fall back to BitBlt()
+ const int caps = ::GetDeviceCaps(GetHdc(), RASTERCAPS);
+ if ( bmpSrc.Ok() && (caps & RC_STRETCHDIB) )
{
- StretchBltModeChanger changeMode(GetHdc(), COLORONCOLOR);
+ DIBSECTION ds;
+ wxZeroMemory(ds);
- success = ::StretchBlt
- (
- GetHdc(),
- xdest, ydest, width, height,
- GetHdcOf(*source),
- xsrc, ysrc, width, height,
- dwRop
- ) != 0;
+ if ( ::GetObject(GetHbitmapOf(bmpSrc),
+ sizeof(ds),
+ &ds) == sizeof(ds) )
+ {
+ StretchBltModeChanger changeMode(GetHdc(), COLORONCOLOR);
+
+ if ( ::StretchDIBits(GetHdc(),
+ xdest, ydest,
+ width, height,
+ 0, 0,
+ width, height,
+ ds.dsBm.bmBits,
+ (LPBITMAPINFO)&ds.dsBmih,
+ DIB_RGB_COLORS,
+ SRCCOPY
+ ) == (int)GDI_ERROR )
+ {
+ wxLogLastError(wxT("StretchDIBits"));
+ }
+ else
+ {
+ success = TRUE;
+ }
+ }
}
- else
+
+ if ( !success && (caps & RC_STRETCHBLT) )
{
- success = ::BitBlt
- (
- GetHdc(),
- xdest, ydest,
- (int)width, (int)height,
- GetHdcOf(*source),
- xsrc, ysrc,
- dwRop
- ) != 0;
+ StretchBltModeChanger changeMode(GetHdc(), COLORONCOLOR);
+
+ if ( !::StretchBlt
+ (
+ GetHdc(),
+ xdest, ydest, width, height,
+ GetHdcOf(*source),
+ xsrc, ysrc, width, height,
+ dwRop
+ ) )
+ {
+ wxLogLastError(_T("StretchBlt"));
+ }
+ else
+ {
+ success = TRUE;
+ }
}
if ( !success )
{
- wxLogLastError(wxT("BitBlt/StretchBlt"));
+ if ( !::BitBlt
+ (
+ GetHdc(),
+ xdest, ydest,
+ (int)width, (int)height,
+ GetHdcOf(*source),
+ xsrc, ysrc,
+ dwRop
+ ) )
+ {
+ wxLogLastError(_T("BitBlt"));
+ }
+ else
+ {
+ success = TRUE;
+ }
}
}
wxDCCacheEntry* wxDC::FindBitmapInCache(WXHDC dc, int w, int h)
{
int depth = ::GetDeviceCaps((HDC) dc, PLANES) * ::GetDeviceCaps((HDC) dc, BITSPIXEL);
- wxNode* node = sm_bitmapCache.First();
+ wxNode* node = sm_bitmapCache.GetFirst();
while (node)
{
- wxDCCacheEntry* entry = (wxDCCacheEntry*) node->Data();
+ wxDCCacheEntry* entry = (wxDCCacheEntry*) node->GetData();
if (entry->m_depth == depth)
{
return entry;
}
- node = node->Next();
+ node = node->GetNext();
}
WXHBITMAP hBitmap = (WXHBITMAP) ::CreateCompatibleBitmap((HDC) dc, w, h);
if ( !hBitmap)
wxDCCacheEntry* wxDC::FindDCInCache(wxDCCacheEntry* notThis, WXHDC dc)
{
int depth = ::GetDeviceCaps((HDC) dc, PLANES) * ::GetDeviceCaps((HDC) dc, BITSPIXEL);
- wxNode* node = sm_dcCache.First();
+ wxNode* node = sm_dcCache.GetFirst();
while (node)
{
- wxDCCacheEntry* entry = (wxDCCacheEntry*) node->Data();
+ wxDCCacheEntry* entry = (wxDCCacheEntry*) node->GetData();
// Don't return the same one as we already have
if (!notThis || (notThis != entry))
}
}
- node = node->Next();
+ node = node->GetNext();
}
WXHDC hDC = (WXHDC) ::CreateCompatibleDC((HDC) dc);
if ( !hDC)