Blit code for masks
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9610 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
175
src/os2/dc.cpp
175
src/os2/dc.cpp
@@ -1342,11 +1342,6 @@ bool wxDC::DoBlit(
|
|||||||
CHARBUNDLE vCbnd;
|
CHARBUNDLE vCbnd;
|
||||||
COLORREF vOldTextColor;
|
COLORREF vOldTextColor;
|
||||||
COLORREF vOldBackground = ::GpiQueryBackColor(m_hPS);
|
COLORREF vOldBackground = ::GpiQueryBackColor(m_hPS);
|
||||||
POINTL aPoint[4] = { vXdest, vYdest
|
|
||||||
,vXdest + vWidth, vYdest + vHeight
|
|
||||||
,vXsrc, vYsrc
|
|
||||||
,vXsrc + vWidth, vYsrc + vHeight
|
|
||||||
};
|
|
||||||
|
|
||||||
if (bUseMask)
|
if (bUseMask)
|
||||||
{
|
{
|
||||||
@@ -1407,7 +1402,7 @@ bool wxDC::DoBlit(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool bSuccess;
|
bool bSuccess;
|
||||||
#if 0
|
|
||||||
if (bUseMask)
|
if (bUseMask)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -1415,68 +1410,158 @@ bool wxDC::DoBlit(
|
|||||||
//
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create a temp buffer bitmap and DCs to access it and the mask
|
// Create a temp buffer bitmap and DCs/PSs to access it and the mask
|
||||||
//
|
//
|
||||||
HDC dc_mask = ::CreateCompatibleDC(GetHdcOf(*source));
|
HDC hDCMask;
|
||||||
HDC dc_buffer = ::CreateCompatibleDC(GetHdc());
|
HDC hDCBuffer;
|
||||||
HBITMAP buffer_bmap = ::CreateCompatibleBitmap(GetHdc(), width, height);
|
HPS hPSMask;
|
||||||
::SelectObject(dc_mask, (HBITMAP) mask->GetMaskBitmap());
|
HPS hPSBuffer;
|
||||||
::SelectObject(dc_buffer, buffer_bmap);
|
DEVOPENSTRUC vDOP = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
|
||||||
|
BITMAPINFOHEADER2 vBmpHdr;
|
||||||
|
SIZEL vSize = {0, 0};
|
||||||
|
LONG rc;
|
||||||
|
|
||||||
// copy dest to buffer
|
hDCMask = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDOP, NULLHANDLE);
|
||||||
if ( !::BitBlt(dc_buffer, 0, 0, (int)width, (int)height,
|
hDCBuffer = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDOP, NULLHANDLE);
|
||||||
GetHdc(), xdest, ydest, SRCCOPY) )
|
hPSMask = ::GpiCreatePS(vHabmain, hDCMask, &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC);
|
||||||
|
hPSBuffer = ::GpiCreatePS(vHabmain, hDCBuffer, &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC);
|
||||||
|
|
||||||
|
memset(&vBmpHdr, 0, sizeof(BITMAPINFOHEADER2));
|
||||||
|
vBmpHdr.cbFix = sizeof(BITMAPINFOHEADER2);
|
||||||
|
vBmpHdr.cx = vWidth;
|
||||||
|
vBmpHdr.cy = vHeight;
|
||||||
|
vBmpHdr.cPlanes = 1;
|
||||||
|
vBmpHdr.cBitCount = 24;
|
||||||
|
|
||||||
|
HBITMAP hBufBitmap = ::GpiCreateBitmap(GetHPS(), &vBmpHdr, 0L, NULL, NULL);
|
||||||
|
POINTL aPoint1[4] = { 0, 0
|
||||||
|
,vWidth, vHeight
|
||||||
|
,vXdest, vYdest
|
||||||
|
,vXdest + vWidth, vYdest + vHeight
|
||||||
|
};
|
||||||
|
POINTL aPoint2[4] = { 0, 0
|
||||||
|
,vWidth, vHeight
|
||||||
|
,vXsrc, vYsrc
|
||||||
|
,vXsrc + vWidth, vYsrc + vHeight
|
||||||
|
};
|
||||||
|
POINTL aPoint3[4] = { vXdest, vYdest
|
||||||
|
,vXdest + vWidth, vYdest + vHeight
|
||||||
|
,0, 0
|
||||||
|
,vWidth, vHeight
|
||||||
|
};
|
||||||
|
::GpiSetBitmap(hPSMask, (HBITMAP) pMask->GetMaskBitmap());
|
||||||
|
::GpiSetBitmap(hPSBuffer, (HBITMAP) hBufBitmap);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy dest to buffer
|
||||||
|
//
|
||||||
|
rc = ::GpiBitBlt( hPSBuffer
|
||||||
|
,GetHPS()
|
||||||
|
,4L
|
||||||
|
,aPoint1
|
||||||
|
,ROP_SRCCOPY
|
||||||
|
,BBO_IGNORE
|
||||||
|
);
|
||||||
|
if (rc == GPI_ERROR)
|
||||||
{
|
{
|
||||||
wxLogLastError(wxT("BitBlt"));
|
wxLogLastError(wxT("BitBlt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy src to buffer using selected raster op
|
//
|
||||||
if ( !::BitBlt(dc_buffer, 0, 0, (int)width, (int)height,
|
// Copy src to buffer using selected raster op
|
||||||
GetHdcOf(*source), xsrc, ysrc, dwRop) )
|
//
|
||||||
|
rc = ::GpiBitBlt( hPSBuffer
|
||||||
|
,GetHPS()
|
||||||
|
,4L
|
||||||
|
,aPoint2
|
||||||
|
,lRop
|
||||||
|
,BBO_IGNORE
|
||||||
|
);
|
||||||
|
if (rc == GPI_ERROR)
|
||||||
{
|
{
|
||||||
wxLogLastError(wxT("BitBlt"));
|
wxLogLastError(wxT("BitBlt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// set masked area in buffer to BLACK (pixel value 0)
|
//
|
||||||
COLORREF prevBkCol = ::SetBkColor(GetHdc(), RGB(255, 255, 255));
|
// Set masked area in buffer to BLACK (pixel value 0)
|
||||||
COLORREF prevCol = ::SetTextColor(GetHdc(), RGB(0, 0, 0));
|
//
|
||||||
if ( !::BitBlt(dc_buffer, 0, 0, (int)width, (int)height,
|
COLORREF vPrevBkCol = ::GpiQueryBackColor(GetHPS());
|
||||||
dc_mask, xsrc, ysrc, SRCAND) )
|
COLORREF vPrevCol = ::GpiQueryColor(GetHPS());
|
||||||
|
|
||||||
|
::GpiSetBackColor(GetHPS(), OS2RGB(255, 255, 255));
|
||||||
|
::GpiSetColor(GetHPS(), OS2RGB(0, 0, 0));
|
||||||
|
|
||||||
|
rc = ::GpiBitBlt( hPSBuffer
|
||||||
|
,hPSMask
|
||||||
|
,4L
|
||||||
|
,aPoint2
|
||||||
|
,ROP_SRCAND
|
||||||
|
,BBO_IGNORE
|
||||||
|
);
|
||||||
|
if (rc == GPI_ERROR)
|
||||||
{
|
{
|
||||||
wxLogLastError(wxT("BitBlt"));
|
wxLogLastError(wxT("BitBlt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// set unmasked area in dest to BLACK
|
//
|
||||||
::SetBkColor(GetHdc(), RGB(0, 0, 0));
|
// Set unmasked area in dest to BLACK
|
||||||
::SetTextColor(GetHdc(), RGB(255, 255, 255));
|
//
|
||||||
if ( !::BitBlt(GetHdc(), xdest, ydest, (int)width, (int)height,
|
::GpiSetBackColor(GetHPS(), OS2RGB(0, 0, 0));
|
||||||
dc_mask, xsrc, ysrc, SRCAND) )
|
::GpiSetColor(GetHPS(), OS2RGB(255, 255, 255));
|
||||||
|
rc = ::GpiBitBlt( GetHPS()
|
||||||
|
,hPSMask
|
||||||
|
,4L
|
||||||
|
,aPoint2
|
||||||
|
,ROP_SRCAND
|
||||||
|
,BBO_IGNORE
|
||||||
|
);
|
||||||
|
if (rc == GPI_ERROR)
|
||||||
{
|
{
|
||||||
wxLogLastError(wxT("BitBlt"));
|
wxLogLastError(wxT("BitBlt"));
|
||||||
}
|
}
|
||||||
::SetBkColor(GetHdc(), prevBkCol); // restore colours to original values
|
|
||||||
::SetTextColor(GetHdc(), prevCol);
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Restore colours to original values
|
||||||
|
//
|
||||||
|
::GpiSetBackColor(GetHPS(), vPrevBkCol);
|
||||||
|
::GpiSetColor(GetHPS(), vPrevCol);
|
||||||
|
|
||||||
|
//
|
||||||
// OR buffer to dest
|
// OR buffer to dest
|
||||||
success = ::BitBlt(GetHdc(), xdest, ydest,
|
//
|
||||||
(int)width, (int)height,
|
rc = ::GpiBitBlt( GetHPS()
|
||||||
dc_buffer, 0, 0, SRCPAINT) != 0;
|
,hPSMask
|
||||||
if ( !success )
|
,4L
|
||||||
|
,aPoint2
|
||||||
|
,ROP_SRCPAINT
|
||||||
|
,BBO_IGNORE
|
||||||
|
);
|
||||||
|
if (rc == GPI_ERROR)
|
||||||
{
|
{
|
||||||
|
bSuccess = FALSE;
|
||||||
wxLogLastError(wxT("BitBlt"));
|
wxLogLastError(wxT("BitBlt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// tidy up temporary DCs and bitmap
|
//
|
||||||
::SelectObject(dc_mask, 0);
|
// Tidy up temporary DCs and bitmap
|
||||||
::DeleteDC(dc_mask);
|
//
|
||||||
::SelectObject(dc_buffer, 0);
|
::GpiSetBitmap(hPSMask, NULLHANDLE);
|
||||||
::DeleteDC(dc_buffer);
|
::GpiSetBitmap(hPSBuffer, NULLHANDLE);
|
||||||
::DeleteObject(buffer_bmap);
|
::GpiDestroyPS(hPSMask);
|
||||||
|
::GpiDestroyPS(hPSBuffer);
|
||||||
|
::DevCloseDC(hDCMask);
|
||||||
|
::DevCloseDC(hDCBuffer);
|
||||||
|
::GpiDeleteBitmap(hBufBitmap);
|
||||||
|
bSuccess = TRUE;
|
||||||
}
|
}
|
||||||
}
|
else // no mask, just BitBlt() it
|
||||||
#endif
|
{
|
||||||
// else // no mask, just BitBlt() it
|
POINTL aPoint[4] = { vXdest, vYdest
|
||||||
// {
|
,vXdest + vWidth, vYdest + vHeight
|
||||||
|
,vXsrc, vYsrc
|
||||||
|
,vXsrc + vWidth, vYsrc + vHeight
|
||||||
|
};
|
||||||
|
|
||||||
bSuccess = (::GpiBitBlt( m_hPS
|
bSuccess = (::GpiBitBlt( m_hPS
|
||||||
,pSource->GetHPS()
|
,pSource->GetHPS()
|
||||||
,4L
|
,4L
|
||||||
@@ -1488,7 +1573,7 @@ bool wxDC::DoBlit(
|
|||||||
{
|
{
|
||||||
wxLogLastError(wxT("BitBlt"));
|
wxLogLastError(wxT("BitBlt"));
|
||||||
}
|
}
|
||||||
// }
|
}
|
||||||
vCbnd.lColor = (LONG)vOldTextColor;
|
vCbnd.lColor = (LONG)vOldTextColor;
|
||||||
::GpiSetAttrs( m_hPS // presentation-space handle
|
::GpiSetAttrs( m_hPS // presentation-space handle
|
||||||
,PRIM_CHAR // Char primitive.
|
,PRIM_CHAR // Char primitive.
|
||||||
|
Reference in New Issue
Block a user