Take src x, y into account when blitting with alpha

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33973 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2005-05-06 19:55:46 +00:00
parent 43c3922bb0
commit 3db799025d
2 changed files with 14 additions and 11 deletions

View File

@@ -26,8 +26,9 @@ wxMSW:
- Worked around an apparent bug in deferred window positioning (moving a - Worked around an apparent bug in deferred window positioning (moving a
window from (x, y) to (a, b) and back to (x, y) misses the last step) by window from (x, y) to (a, b) and back to (x, y) misses the last step) by
checking window positions against corresponding sizer state, if any. checking window positions against corresponding sizer state, if any.
- A control's text colour now reflects the system colour setting again. - A control's text colour now reflects the system colour setting.
- Fixed wxFileName::GetLongPath() to behave correctly during the first call too - Fixed wxFileName::GetLongPath() to behave correctly during the first call too.
- Fixed alpha blitting to take into account source position.
wxMac: wxMac:

View File

@@ -131,13 +131,13 @@ static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; }
// otherwise // otherwise
static bool AlphaBlt(HDC hdcDst, static bool AlphaBlt(HDC hdcDst,
int x, int y, int w, int h, int x, int y, int w, int h,
HDC hdcSrc, int srcX, int srcY, HDC hdcSrc,
const wxBitmap& bmpSrc); const wxBitmap& bmpSrc);
#ifdef wxHAVE_RAW_BITMAP #ifdef wxHAVE_RAW_BITMAP
// our (limited) AlphaBlend() replacement // our (limited) AlphaBlend() replacement
static void static void
wxAlphaBlend(HDC hdcDst, int x, int y, int w, int h, const wxBitmap& bmp); wxAlphaBlend(HDC hdcDst, int x, int y, int w, int h, int srcX, int srcY, const wxBitmap& bmp);
#endif #endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -1065,7 +1065,7 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask
MemoryHDC hdcMem; MemoryHDC hdcMem;
SelectInHDC select(hdcMem, GetHbitmapOf(bmp)); SelectInHDC select(hdcMem, GetHbitmapOf(bmp));
if ( AlphaBlt(GetHdc(), x, y, width, height, hdcMem, bmp) ) if ( AlphaBlt(GetHdc(), x, y, width, height, 0, 0, hdcMem, bmp) )
return; return;
} }
@@ -1913,7 +1913,7 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
(m_selectedBitmap.Ok() && m_selectedBitmap.HasAlpha())) ) (m_selectedBitmap.Ok() && m_selectedBitmap.HasAlpha())) )
{ {
if ( AlphaBlt(GetHdc(), xdest, ydest, width, height, if ( AlphaBlt(GetHdc(), xdest, ydest, width, height,
GetHdcOf(*source), bmpSrc) ) xsrc, ysrc, GetHdcOf(*source), bmpSrc) )
return true; return true;
} }
@@ -2388,7 +2388,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxDCModule, wxModule)
static bool AlphaBlt(HDC hdcDst, static bool AlphaBlt(HDC hdcDst,
int x, int y, int width, int height, int x, int y, int width, int height,
HDC hdcSrc, int srcX, int srcY, HDC hdcSrc,
const wxBitmap& bmp) const wxBitmap& bmp)
{ {
wxASSERT_MSG( bmp.Ok() && bmp.HasAlpha(), _T("AlphaBlt(): invalid bitmap") ); wxASSERT_MSG( bmp.Ok() && bmp.HasAlpha(), _T("AlphaBlt(): invalid bitmap") );
@@ -2436,7 +2436,7 @@ static bool AlphaBlt(HDC hdcDst,
bf.AlphaFormat = AC_SRC_ALPHA; bf.AlphaFormat = AC_SRC_ALPHA;
if ( pfnAlphaBlend(hdcDst, x, y, width, height, if ( pfnAlphaBlend(hdcDst, x, y, width, height,
hdcSrc, 0, 0, width, height, hdcSrc, srcX, srcY, width, height,
bf) ) bf) )
{ {
// skip wxAlphaBlend() call below // skip wxAlphaBlend() call below
@@ -2450,7 +2450,7 @@ static bool AlphaBlt(HDC hdcDst,
// AlphaBlend() unavailable of failed: use our own (probably much slower) // AlphaBlend() unavailable of failed: use our own (probably much slower)
// implementation // implementation
#ifdef wxHAVE_RAW_BITMAP #ifdef wxHAVE_RAW_BITMAP
wxAlphaBlend(hdcDst, x, y, width, height, bmp); wxAlphaBlend(hdcDst, x, y, width, height, srcX, srcY, bmp);
return true; return true;
#else // !wxHAVE_RAW_BITMAP #else // !wxHAVE_RAW_BITMAP
@@ -2466,7 +2466,7 @@ static bool AlphaBlt(HDC hdcDst,
#ifdef wxHAVE_RAW_BITMAP #ifdef wxHAVE_RAW_BITMAP
static void static void
wxAlphaBlend(HDC hdcDst, int xDst, int yDst, int w, int h, const wxBitmap& bmpSrc) wxAlphaBlend(HDC hdcDst, int xDst, int yDst, int w, int h, int srcX, int srcY, const wxBitmap& bmpSrc)
{ {
// get the destination DC pixels // get the destination DC pixels
wxBitmap bmpDst(w, h, 32 /* force creating RGBA DIB */); wxBitmap bmpDst(w, h, 32 /* force creating RGBA DIB */);
@@ -2488,11 +2488,13 @@ wxAlphaBlend(HDC hdcDst, int xDst, int yDst, int w, int h, const wxBitmap& bmpSr
wxAlphaPixelData::Iterator pDst(dataDst), wxAlphaPixelData::Iterator pDst(dataDst),
pSrc(dataSrc); pSrc(dataSrc);
pSrc.Offset(dataSrc, srcX, srcY);
for ( int y = 0; y < h; y++ ) for ( int y = 0; y < h; y++ )
{ {
wxAlphaPixelData::Iterator pDstRowStart = pDst, wxAlphaPixelData::Iterator pDstRowStart = pDst,
pSrcRowStart = pSrc; pSrcRowStart = pSrc;
for ( int x = 0; x < w; x++ ) for ( int x = 0; x < w; x++ )
{ {
// note that source bitmap uses premultiplied alpha (as required by // note that source bitmap uses premultiplied alpha (as required by