From b95f2b699d99d63f68376c6e80a2e441c1ee39be Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 28 Jun 2022 22:50:24 +0200 Subject: [PATCH] Clarify that wxDC::CopyAttributes() doesn't copy scaling factor Also show an example of setting the scaling factor in wxMemoryDC documentation. --- interface/wx/dc.h | 3 +++ interface/wx/dcmemory.h | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/interface/wx/dc.h b/interface/wx/dc.h index 52a9905206..09b5015897 100644 --- a/interface/wx/dc.h +++ b/interface/wx/dc.h @@ -1500,6 +1500,9 @@ public: - Background brush - Layout direction + Note that the scaling factor is not considered to be an attribute of + wxDC and is @e not copied by this function. + @param dc A valid (i.e. its IsOk() must return @true) source device context. */ diff --git a/interface/wx/dcmemory.h b/interface/wx/dcmemory.h index d7c4dfa3f9..b30bd19ee6 100644 --- a/interface/wx/dcmemory.h +++ b/interface/wx/dcmemory.h @@ -38,6 +38,25 @@ This happens automatically when wxMemoryDC object goes out of scope. + Note that the scaling factor of the bitmap determines the scaling factor + used by this device context, so when using a memory device context as a + back buffer for a window, you should typically create the bitmap using the + same scale factor as used by the window, e.g. + @code + void MyWindow::OnPaint(wxPaintEvent&) + { + wxBitmap bmp; + bmp.CreateWithDIPSize(GetClientSize(), GetDPIScaleFactor()); + { + wxMemoryDC memdc(bmp); + ... use memdc to draw on the bitmap ... + } + + wxPaintDC dc(this); + dc.DrawBitmap(bmp, wxPoint(0, 0)); + } + @endcode + @library{wxcore} @category{dc}