#include "wx/sysopt.h"
#include "wx/dcprint.h"
#include "wx/module.h"
+#include "wx/dynload.h"
#include <string.h>
#include <math.h>
if (m_oldBitmap)
{
::SelectObject((HDC) dc, (HBITMAP) m_oldBitmap);
+#ifdef __WXDEBUG__
if (m_selectedBitmap.Ok())
{
m_selectedBitmap.SetSelectedInto(NULL);
}
+#endif
}
m_oldBitmap = 0;
if (m_oldPen)
HPALETTE oldPal = 0;
#endif // wxUSE_PALETTE
+ // do we have AlphaBlend() and company in the headers?
+#ifdef AC_SRC_OVER
+ if ( bmp.HasAlpha() )
+ {
+ // yes, now try to see if we have it during run-time
+
+ typedef BOOL (WINAPI *AlphaBlend_t)(HDC,int,int,int,int,
+ HDC,int,int,int,int,
+ BLENDFUNCTION);
+
+ // bitmaps can be drawn only from GUI thread so there is no need to
+ // protect this static variable from multiple threads
+ static bool s_triedToLoad = FALSE;
+ static AlphaBlend_t pfnAlphaBlend = NULL;
+ if ( !s_triedToLoad )
+ {
+ s_triedToLoad = TRUE;
+
+ wxDynamicLibrary dll(_T("msimg32.dll"));
+ if ( dll.IsLoaded() )
+ {
+ pfnAlphaBlend = (AlphaBlend_t)dll.GetSymbol(_T("AlphaBlend"));
+ if ( pfnAlphaBlend )
+ {
+ // we must keep the DLL loaded if we want to be able to
+ // call AlphaBlend() so just never unload it at all
+ dll.Detach();
+ }
+ }
+ }
+
+ if ( pfnAlphaBlend )
+ {
+ MemoryHDC hdcMem;
+ SelectInHDC select(hdcMem, GetHbitmapOf(bmp));
+
+#ifndef AC_SRC_ALPHA
+ #define AC_SRC_ALPHA 1
+#endif
+
+ BLENDFUNCTION bf;
+ bf.BlendOp = AC_SRC_OVER;
+ bf.BlendFlags = 0;
+ bf.SourceConstantAlpha = 0xff;
+ bf.AlphaFormat = AC_SRC_ALPHA;
+
+ if ( !pfnAlphaBlend(GetHdc(), x, y, width, height,
+ hdcMem, 0, 0, width, height,
+ bf) )
+ {
+ wxLogLastError(_T("AlphaBlend"));
+ }
+
+ return;
+ }
+ //else: AlphaBlend() not available
+ }
+#endif // defined(AC_SRC_OVER)
+
if ( useMask )
{
wxMask *mask = bmp.GetMask();
m_logicalScaleY = y;
}
-#if WXWIN_COMPATIBILITY
-void wxDC::DoGetTextExtent(const wxString& string, float *x, float *y,
- float *descent, float *externalLeading,
- wxFont *theFont, bool use16bit) const
-{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
-
- wxCoord x1, y1, descent1, externalLeading1;
- GetTextExtent(string, & x1, & y1, & descent1, & externalLeading1, theFont, use16bit);
- *x = x1; *y = y1;
- if (descent)
- *descent = descent1;
- if (externalLeading)
- *externalLeading = externalLeading1;
-}
-#endif
-
#if wxUSE_DC_CACHEING
/*