Use correct wxBitmap size for STC

Create the wxBitmap in the expected physical size to fix rendering artifacts.
CreateWithDIPSize cannot be used because when it scales the DIP size, it could
be off-by-one.

Remove obsolete mdc->GetImpl()->SetWindow(), this is not needed anymore because
the DPI is now determined from the associated bitmap content scale factor, and
not from the wxWindow.

See #22450
This commit is contained in:
Maarten Bent
2022-05-28 20:12:07 +02:00
parent 655afd6030
commit 31de97a2c6

View File

@@ -293,13 +293,12 @@ void SurfaceImpl::InitPixMap(int width, int height, Surface *surface, WindowID w
wxMemoryDC* mdc = surface
? new wxMemoryDC(static_cast<SurfaceImpl*>(surface)->hdc)
: new wxMemoryDC();
mdc->GetImpl()->SetWindow(GETWIN(winid));
hdc = mdc;
hdcOwned = true;
if (width < 1) width = 1;
if (height < 1) height = 1;
bitmap = new wxBitmap();
bitmap->CreateWithDIPSize(width, height,(GETWIN(winid))->GetDPIScaleFactor());
bitmap = new wxBitmap(GETWIN(winid)->ToPhys(wxSize(width, height)));
bitmap->SetScaleFactor(GETWIN(winid)->GetDPIScaleFactor());
mdc->SelectObject(*bitmap);
}