+bool wxPrinterDC::DoBlit(wxCoord xdest, wxCoord ydest,
+ wxCoord width, wxCoord height,
+ wxDC *source,
+ wxCoord WXUNUSED(xsrc), wxCoord WXUNUSED(ysrc),
+ int WXUNUSED(rop), bool useMask,
+ wxCoord WXUNUSED(xsrcMask), wxCoord WXUNUSED(ysrcMask))
+{
+ wxBitmap& bmp = source->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(*source);
+ 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);
+ }
+ }
+ }
+ }
+ else // no mask
+ {
+ if ( !(::GetDeviceCaps(GetHdc(), RASTERCAPS) & RC_STRETCHDIB) ||
+ !DrawBitmapUsingStretchDIBits(GetHdc(), bmp, xdest, ydest) )
+ {
+ // no support for StretchDIBits
+
+ // as we are printing, source colours are screen colours not
+ // printer colours and so we need copy the bitmap pixel by pixel.
+ HDC dcSrc = GetHdcOf(*source);
+ RECT rect;
+ for (int y = 0; y < height; y++)
+ {
+ // optimization: draw identical adjacent pixels together.
+ for (int x = 0; x < width; x++)
+ {
+ COLORREF col = ::GetPixel(dcSrc, x, y);
+ HBRUSH brush = ::CreateSolidBrush( col );
+
+ rect.left = xdest + x;
+ rect.top = ydest + y;
+ while( (x + 1 < width) &&
+ (::GetPixel(dcSrc, x + 1, y) == col ) )
+ {
+ ++x;
+ }
+ rect.right = xdest + x + 1;
+ rect.bottom = rect.top + 1;
+ ::FillRect((HDC) m_hDC, &rect, brush);
+ ::DeleteObject(brush);
+ }
+ }
+ }
+ }
+
+ return true;
+}
+
+#endif
+ // wxUSE_PRINTING_ARCHITECTURE