// Modified by:
// Created: 01/02/97
// RCS-ID: $Id$
-// Copyright: (c) Julian Smart and Markus Holzem
+// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
{
s_triedToLoad = TRUE;
+ // don't give errors about the DLL being unavailable, we're
+ // prepared to handle this
+ wxLogNull nolog;
+
wxDynamicLibrary dll(_T("msimg32.dll"));
if ( dll.IsLoaded() )
{
if ( pfnAlphaBlend )
{
// we must keep the DLL loaded if we want to be able to
- // call AlphaBlend() so just never unload it at all
+ // call AlphaBlend() so just never unload it at all, not a
+ // big deal
dll.Detach();
}
}
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)