+bool wxPrinterDCImpl::DoBlit(wxCoord xdest, wxCoord ydest,
+ wxCoord width, wxCoord height,
+ wxDC *source,
+ wxCoord WXUNUSED(xsrc), wxCoord WXUNUSED(ysrc),
+ wxRasterOperationMode WXUNUSED(rop), bool useMask,
+ wxCoord WXUNUSED(xsrcMask), wxCoord WXUNUSED(ysrcMask))
+{
+ wxDCImpl *impl = source->GetImpl();
+ wxMSWDCImpl *msw_impl = wxDynamicCast(impl, wxMSWDCImpl);
+ if (!msw_impl)
+ return false;
+
+ wxBitmap& bmp = msw_impl->GetSelectedBitmap();
+ wxMask *mask = useMask ? bmp.GetMask() : NULL;
+ if ( mask )
+ {
+ // If we are printing source colours are screen colours not printer
+ // colours and so we need copy the bitmap pixel by pixel.
+ RECT rect;
+ HDC dcSrc = GetHdcOf(*msw_impl);
+ MemoryHDC dcMask(dcSrc);
+ SelectInHDC selectMask(dcMask, (HBITMAP)mask->GetMaskBitmap());
+
+ for (int x = 0; x < width; x++)
+ {
+ for (int y = 0; y < height; y++)
+ {
+ COLORREF cref = ::GetPixel(dcMask, x, y);
+ if (cref)
+ {
+ HBRUSH brush = ::CreateSolidBrush(::GetPixel(dcSrc, x, y));
+ rect.left = xdest + x;
+ rect.right = rect.left + 1;
+ rect.top = ydest + y;
+ rect.bottom = rect.top + 1;
+ ::FillRect(GetHdc(), &rect, brush);
+ ::DeleteObject(brush);
+ }
+ }
+ }