use StretchDIBits() if we're drawing a DIB and not a DDB in Blit()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19789 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2003-03-24 23:10:41 +00:00
parent 2f52b4e15c
commit d80f416f62

View File

@@ -1828,13 +1828,14 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
if (!GetHDC()) return FALSE; if (!GetHDC()) return FALSE;
#endif #endif
const wxBitmap& bmpSrc = source->m_selectedBitmap;
wxMask *mask = NULL; wxMask *mask = NULL;
if ( useMask ) if ( useMask )
{ {
const wxBitmap& bmp = source->m_selectedBitmap; mask = bmpSrc.GetMask();
mask = bmp.GetMask();
if ( !(bmp.Ok() && mask && mask->GetMaskBitmap()) ) if ( !(bmpSrc.Ok() && mask && mask->GetMaskBitmap()) )
{ {
// don't give assert here because this would break existing // don't give assert here because this would break existing
// programs - just silently ignore useMask parameter // programs - just silently ignore useMask parameter
@@ -1998,36 +1999,79 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
} }
else // no mask, just BitBlt() it else // no mask, just BitBlt() it
{ {
// use StretchBlt() if available // if we already have a DIB, draw it using StretchDIBits(), otherwise
if ( ::GetDeviceCaps(GetHdc(), RASTERCAPS) & RC_STRETCHBLT ) // use StretchBlt() if available and finally fall back to BitBlt()
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);
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;
}
}
}
if ( !success && (caps & RC_STRETCHBLT) )
{ {
StretchBltModeChanger changeMode(GetHdc(), COLORONCOLOR); StretchBltModeChanger changeMode(GetHdc(), COLORONCOLOR);
success = ::StretchBlt if ( !::StretchBlt
( (
GetHdc(), GetHdc(),
xdest, ydest, width, height, xdest, ydest, width, height,
GetHdcOf(*source), GetHdcOf(*source),
xsrc, ysrc, width, height, xsrc, ysrc, width, height,
dwRop dwRop
) != 0; ) )
} {
else wxLogLastError(_T("StretchBlt"));
{ }
success = ::BitBlt else
( {
GetHdc(), success = TRUE;
xdest, ydest, }
(int)width, (int)height,
GetHdcOf(*source),
xsrc, ysrc,
dwRop
) != 0;
} }
if ( !success ) 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;
}
} }
} }