wxMemoryDC docs (Issue #25738)

17 views
Skip to first unread message

PB

unread,
Aug 29, 2025, 3:07:43 PMAug 29
to wx-...@googlegroups.com, Subscribed
PBfordev created an issue (wxWidgets/wxWidgets#25738)

wxMemoryDC docs has text and code:

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.

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));
}

Is this correct: If my DPI scaling factor is 1.25, the bitmap dimensions will be 1.25 times larger than my window client area (on Windows)?

Docs for wxBitmap::CreateWithDIPSize() has

This should be used when the bitmap size is fixed (e.g. at compile-time) and not if it comes from wxWindow::GetSize() or other similar functions – use CreateWithLogicalSize() in the latter case.

Should not a wxBitmap used as a window backbuffer rather use wxBitmap::CreateWithLogicalSize(), which has in its description:

This should be typically used when creating bitmaps associated to a window area, e.g. to create a bitmap covering the entire window the size parameter should be wxWindow::GetClientSize() and scale should be the wxWindow::GetDPIScaleFactor().

But maybe it is me who is confused and not the docs which is confusing, I am on Windows where the logical and physical pixels are the same...


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/25738@github.com>

VZ

unread,
Sep 8, 2025, 5:01:50 PM (6 days ago) Sep 8
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25738)

Thank you, this is indeed wrong and we should use CreateWithLogicalSize() here, will fix.

I am on Windows where the logical and physical pixels are the same...

Yes, but still different from DIP ones, so this is precisely the platform where the current docs are wrong.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/25738/3268006065@github.com>

VZ

unread,
Sep 8, 2025, 5:12:09 PM (6 days ago) Sep 8
to wx-...@googlegroups.com, Subscribed

Closed #25738 as completed via a7635a3.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issue/25738/issue_event/19574416929@github.com>

Reply all
Reply to author
Forward
0 new messages